Kaydet (Commit) 87e33366 authored tarafından Norbert Thiebaud's avatar Norbert Thiebaud Kaydeden (comit) Miklos Vajna

gridfixes: when the table controls doesn't have the focus use diff. color.

use a different color to paint the selection,
to be consistent with all our other controls

Change-Id: Ia5160dfb769279e2a8a3458b16fe8f6cec08145e
Reviewed-on: https://gerrit.libreoffice.org/537Reviewed-by: 's avatarMiklos Vajna <vmiklos@suse.cz>
Tested-by: 's avatarMiklos Vajna <vmiklos@suse.cz>
üst 9684b9b6
...@@ -80,15 +80,15 @@ namespace svt { namespace table ...@@ -80,15 +80,15 @@ namespace svt { namespace table
virtual void PaintColumnHeader( ColPos _nCol, bool _bActive, bool _bSelected, virtual void PaintColumnHeader( ColPos _nCol, bool _bActive, bool _bSelected,
OutputDevice& _rDevice, const Rectangle& _rArea, OutputDevice& _rDevice, const Rectangle& _rArea,
const StyleSettings& _rStyle ); const StyleSettings& _rStyle );
virtual void PrepareRow( RowPos _nRow, bool _bActive, bool _bSelected, virtual void PrepareRow( RowPos _nRow, bool i_hasControlFocus, bool _bSelected,
OutputDevice& _rDevice, const Rectangle& _rRowArea, OutputDevice& _rDevice, const Rectangle& _rRowArea,
const StyleSettings& _rStyle ); const StyleSettings& _rStyle );
virtual void PaintRowHeader( virtual void PaintRowHeader(
bool _bActive, bool _bSelected, bool i_hasControlFocus, bool _bSelected,
OutputDevice& _rDevice, const Rectangle& _rArea, OutputDevice& _rDevice, const Rectangle& _rArea,
const StyleSettings& _rStyle ); const StyleSettings& _rStyle );
virtual void PaintCell( ColPos const i_col, virtual void PaintCell( ColPos const i_col,
bool _bActive, bool _bSelected, bool i_hasControlFocus, bool _bSelected,
OutputDevice& _rDevice, const Rectangle& _rArea, OutputDevice& _rDevice, const Rectangle& _rArea,
const StyleSettings& _rStyle ); const StyleSettings& _rStyle );
virtual void ShowCellCursor( Window& _rView, const Rectangle& _rCursorRect); virtual void ShowCellCursor( Window& _rView, const Rectangle& _rCursorRect);
......
...@@ -134,9 +134,8 @@ namespace svt { namespace table ...@@ -134,9 +134,8 @@ namespace svt { namespace table
However, the renderer is also allowed to render any However, the renderer is also allowed to render any
cell-independent content of this row. cell-independent content of this row.
@param _bActive @param i_hasControlFocus
<TRUE/> if and only if the row to be painted contains the <TRUE/> if and only if the table control currently has the focus
currently active cell.
@param _bSelected @param _bSelected
<TRUE/> if and only if the row to be prepared is <TRUE/> if and only if the row to be prepared is
selected currently. selected currently.
...@@ -148,7 +147,7 @@ namespace svt { namespace table ...@@ -148,7 +147,7 @@ namespace svt { namespace table
@param _rStyle @param _rStyle
the style to be used for drawing the style to be used for drawing
*/ */
virtual void PrepareRow( RowPos _nRow, bool _bActive, bool _bSelected, virtual void PrepareRow( RowPos _nRow, bool i_hasControlFocus, bool _bSelected,
OutputDevice& _rDevice, const Rectangle& _rRowArea, OutputDevice& _rDevice, const Rectangle& _rRowArea,
const StyleSettings& _rStyle ) = 0; const StyleSettings& _rStyle ) = 0;
...@@ -157,9 +156,8 @@ namespace svt { namespace table ...@@ -157,9 +156,8 @@ namespace svt { namespace table
The row to be painted is denoted by the most recent call to The row to be painted is denoted by the most recent call to
->PrepareRow. ->PrepareRow.
@param _bActive @param i_hasControlFocus
<TRUE/> if and only if the row to be painted contains the <TRUE/> if and only if the table control currently has the focus
currently active cell.
<br/> <br/>
Note that this flag is equal to the respective flag in the Note that this flag is equal to the respective flag in the
previous ->PrepareRow call, it's passed here for convinience previous ->PrepareRow call, it's passed here for convinience
...@@ -178,9 +176,9 @@ namespace svt { namespace table ...@@ -178,9 +176,9 @@ namespace svt { namespace table
@param _rStyle @param _rStyle
the style to be used for drawing the style to be used for drawing
*/ */
virtual void PaintRowHeader( bool _bActive, bool _bSelected, virtual void PaintRowHeader( bool i_hasControlFocus, bool _bSelected,
OutputDevice& _rDevice, const Rectangle& _rArea, OutputDevice& _rDevice, Rectangle const & _rArea,
const StyleSettings& _rStyle ) = 0; StyleSettings const & _rStyle ) = 0;
/** paints a certain cell /** paints a certain cell
...@@ -195,8 +193,8 @@ namespace svt { namespace table ...@@ -195,8 +193,8 @@ namespace svt { namespace table
Note that this flag is equal to the respective flag in the Note that this flag is equal to the respective flag in the
previous ->PrepareRow call, it's passed here for convinience previous ->PrepareRow call, it's passed here for convinience
only. only.
@param _bActive @param i_hasControlFocus
<TRUE/> if the cell is currently active. <TRUE/> if and only if the table control currently has the focus
<br/> <br/>
Note that this flag is equal to the respective flag in the Note that this flag is equal to the respective flag in the
previous ->PrepareRow call, it's passed here for convinience previous ->PrepareRow call, it's passed here for convinience
...@@ -209,7 +207,7 @@ namespace svt { namespace table ...@@ -209,7 +207,7 @@ namespace svt { namespace table
the style to be used for drawing the style to be used for drawing
*/ */
virtual void PaintCell( ColPos const i_col, virtual void PaintCell( ColPos const i_col,
bool _bActive, bool _bSelected, bool i_hasControlFocus, bool _bSelected,
OutputDevice& _rDevice, const Rectangle& _rArea, OutputDevice& _rDevice, const Rectangle& _rArea,
const StyleSettings& _rStyle ) = 0; const StyleSettings& _rStyle ) = 0;
......
...@@ -320,7 +320,7 @@ namespace svt { namespace table ...@@ -320,7 +320,7 @@ namespace svt { namespace table
} }
//------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------
void GridTableRenderer::PrepareRow( RowPos _nRow, bool _bActive, bool _bSelected, void GridTableRenderer::PrepareRow( RowPos _nRow, bool i_hasControlFocus, bool _bSelected,
OutputDevice& _rDevice, const Rectangle& _rRowArea, const StyleSettings& _rStyle ) OutputDevice& _rDevice, const Rectangle& _rRowArea, const StyleSettings& _rStyle )
{ {
// remember the row for subsequent calls to the other ->ITableRenderer methods // remember the row for subsequent calls to the other ->ITableRenderer methods
...@@ -336,7 +336,7 @@ namespace svt { namespace table ...@@ -336,7 +336,7 @@ namespace svt { namespace table
if ( _bSelected ) if ( _bSelected )
{ {
// selected rows use the background color from the style // selected rows use the background color from the style
backgroundColor = _rStyle.GetHighlightColor(); backgroundColor = i_hasControlFocus ? _rStyle.GetHighlightColor() : _rStyle.GetDeactiveColor();
if ( !aLineColor ) if ( !aLineColor )
lineColor = backgroundColor; lineColor = backgroundColor;
} }
...@@ -380,13 +380,10 @@ namespace svt { namespace table ...@@ -380,13 +380,10 @@ namespace svt { namespace table
_rDevice.DrawRect( _rRowArea ); _rDevice.DrawRect( _rRowArea );
_rDevice.Pop(); _rDevice.Pop();
(void)_bActive;
// row containing the active cell not rendered any special at the moment
} }
//------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------
void GridTableRenderer::PaintRowHeader( bool _bActive, bool _bSelected, OutputDevice& _rDevice, const Rectangle& _rArea, void GridTableRenderer::PaintRowHeader( bool i_hasControlFocus, bool _bSelected, OutputDevice& _rDevice, const Rectangle& _rArea,
const StyleSettings& _rStyle ) const StyleSettings& _rStyle )
{ {
_rDevice.Push( PUSH_LINECOLOR | PUSH_TEXTCOLOR ); _rDevice.Push( PUSH_LINECOLOR | PUSH_TEXTCOLOR );
...@@ -409,8 +406,7 @@ namespace svt { namespace table ...@@ -409,8 +406,7 @@ namespace svt { namespace table
_rDevice.DrawText( aTextRect, rowTitle, nDrawTextFlags ); _rDevice.DrawText( aTextRect, rowTitle, nDrawTextFlags );
} }
// TODO: active? selected? (void)i_hasControlFocus;
(void)_bActive;
(void)_bSelected; (void)_bSelected;
_rDevice.Pop(); _rDevice.Pop();
} }
...@@ -436,7 +432,7 @@ namespace svt { namespace table ...@@ -436,7 +432,7 @@ namespace svt { namespace table
}; };
//------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------
void GridTableRenderer::PaintCell( ColPos const i_column, bool _bSelected, bool _bActive, void GridTableRenderer::PaintCell( ColPos const i_column, bool _bSelected, bool i_hasControlFocus,
OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle ) OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle )
{ {
_rDevice.Push( PUSH_LINECOLOR | PUSH_FILLCOLOR ); _rDevice.Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
...@@ -453,7 +449,7 @@ namespace svt { namespace table ...@@ -453,7 +449,7 @@ namespace svt { namespace table
if ( _bSelected && !aLineColor ) if ( _bSelected && !aLineColor )
{ {
// if no line color is specified by the model, use the usual selection color for lines in selected cells // if no line color is specified by the model, use the usual selection color for lines in selected cells
lineColor = _rStyle.GetHighlightColor(); lineColor = i_hasControlFocus ? _rStyle.GetHighlightColor() : _rStyle.GetDeactiveColor();
} }
_rDevice.SetLineColor( lineColor ); _rDevice.SetLineColor( lineColor );
...@@ -462,9 +458,6 @@ namespace svt { namespace table ...@@ -462,9 +458,6 @@ namespace svt { namespace table
} }
_rDevice.Pop(); _rDevice.Pop();
(void)_bActive;
// no special painting for the active cell at the moment
} }
//------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------
......
...@@ -106,6 +106,10 @@ namespace svt { namespace table ...@@ -106,6 +106,10 @@ namespace svt { namespace table
// forward certain settings to the data window // forward certain settings to the data window
switch ( i_nStateChange ) switch ( i_nStateChange )
{ {
case STATE_CHANGE_CONTROL_FOCUS:
m_pImpl->invalidateSelectedRows();
break;
case STATE_CHANGE_CONTROLBACKGROUND: case STATE_CHANGE_CONTROLBACKGROUND:
if ( IsControlBackground() ) if ( IsControlBackground() )
getDataWindow().SetControlBackground( GetControlBackground() ); getDataWindow().SetControlBackground( GetControlBackground() );
......
...@@ -1404,14 +1404,14 @@ namespace svt { namespace table ...@@ -1404,14 +1404,14 @@ namespace svt { namespace table
if ( _rUpdateRect.GetIntersection( aRowIterator.getRect() ).IsEmpty() ) if ( _rUpdateRect.GetIntersection( aRowIterator.getRect() ).IsEmpty() )
continue; continue;
bool const isActiveRow = ( aRowIterator.getRow() == getCurrentRow() ); bool const isControlFocused = m_rAntiImpl.HasControlFocus();
bool const isSelectedRow = isRowSelected( aRowIterator.getRow() ); bool const isSelectedRow = isRowSelected( aRowIterator.getRow() );
Rectangle const aRect = aRowIterator.getRect().GetIntersection( aAllDataCellsArea ); Rectangle const aRect = aRowIterator.getRect().GetIntersection( aAllDataCellsArea );
// give the redenderer a chance to prepare the row // give the redenderer a chance to prepare the row
pRenderer->PrepareRow( pRenderer->PrepareRow(
aRowIterator.getRow(), isActiveRow, isSelectedRow, aRowIterator.getRow(), isControlFocused, isSelectedRow,
*m_pDataWindow, aRect, rStyle *m_pDataWindow, aRect, rStyle
); );
...@@ -1419,7 +1419,7 @@ namespace svt { namespace table ...@@ -1419,7 +1419,7 @@ namespace svt { namespace table
if ( m_pModel->hasRowHeaders() ) if ( m_pModel->hasRowHeaders() )
{ {
const Rectangle aCurrentRowHeader( aRowHeaderArea.GetIntersection( aRowIterator.getRect() ) ); const Rectangle aCurrentRowHeader( aRowHeaderArea.GetIntersection( aRowIterator.getRect() ) );
pRenderer->PaintRowHeader( isActiveRow, isSelectedRow, *m_pDataWindow, aCurrentRowHeader, pRenderer->PaintRowHeader( isControlFocused, isSelectedRow, *m_pDataWindow, aCurrentRowHeader,
rStyle ); rStyle );
} }
...@@ -1433,7 +1433,7 @@ namespace svt { namespace table ...@@ -1433,7 +1433,7 @@ namespace svt { namespace table
) )
{ {
bool isSelectedColumn = false; bool isSelectedColumn = false;
pRenderer->PaintCell( aCell.getColumn(), isSelectedRow || isSelectedColumn, isActiveRow, pRenderer->PaintCell( aCell.getColumn(), isSelectedRow || isSelectedColumn, isControlFocused,
*m_pDataWindow, aCell.getRect(), rStyle ); *m_pDataWindow, aCell.getRect(), rStyle );
} }
} }
...@@ -1465,30 +1465,25 @@ namespace svt { namespace table ...@@ -1465,30 +1465,25 @@ namespace svt { namespace table
bool bSuccess = false; bool bSuccess = false;
bool selectionChanged = false; bool selectionChanged = false;
Rectangle rCells;
switch ( _eAction ) switch ( _eAction )
{ {
case cursorDown: case cursorDown:
if(m_pSelEngine->GetSelectionMode() == SINGLE_SELECTION) if ( m_pSelEngine->GetSelectionMode() == SINGLE_SELECTION )
{ {
//if other rows already selected, deselect them //if other rows already selected, deselect them
if(!m_aSelectedRows.empty()) if(!m_aSelectedRows.empty())
{ {
for(std::vector<RowPos>::iterator it=m_aSelectedRows.begin(); invalidateSelectedRows();
it!=m_aSelectedRows.end();++it)
{
invalidateSelectedRegion(*it, *it, rCells);
}
m_aSelectedRows.clear(); m_aSelectedRows.clear();
} }
if(m_nCurRow < m_nRowCount-1) if ( m_nCurRow < m_nRowCount-1 )
{ {
++m_nCurRow; ++m_nCurRow;
m_aSelectedRows.push_back(m_nCurRow); m_aSelectedRows.push_back(m_nCurRow);
} }
else else
m_aSelectedRows.push_back(m_nCurRow); m_aSelectedRows.push_back(m_nCurRow);
invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); invalidateRow( m_nCurRow );
ensureVisible(m_nCurColumn,m_nCurRow,false); ensureVisible(m_nCurColumn,m_nCurRow,false);
selectionChanged = true; selectionChanged = true;
bSuccess = true; bSuccess = true;
...@@ -1505,23 +1500,19 @@ namespace svt { namespace table ...@@ -1505,23 +1500,19 @@ namespace svt { namespace table
{ {
if(!m_aSelectedRows.empty()) if(!m_aSelectedRows.empty())
{ {
for(std::vector<RowPos>::iterator it=m_aSelectedRows.begin(); invalidateSelectedRows();
it!=m_aSelectedRows.end();++it)
{
invalidateSelectedRegion(*it, *it, rCells);
}
m_aSelectedRows.clear(); m_aSelectedRows.clear();
} }
if(m_nCurRow>0) if(m_nCurRow>0)
{ {
--m_nCurRow; --m_nCurRow;
m_aSelectedRows.push_back(m_nCurRow); m_aSelectedRows.push_back(m_nCurRow);
invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); invalidateRow( m_nCurRow );
} }
else else
{ {
m_aSelectedRows.push_back(m_nCurRow); m_aSelectedRows.push_back(m_nCurRow);
invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); invalidateRow( m_nCurRow );
} }
ensureVisible(m_nCurColumn,m_nCurRow,false); ensureVisible(m_nCurColumn,m_nCurRow,false);
selectionChanged = true; selectionChanged = true;
...@@ -1603,7 +1594,7 @@ namespace svt { namespace table ...@@ -1603,7 +1594,7 @@ namespace svt { namespace table
//else select the row->put it in the vector //else select the row->put it in the vector
else else
m_aSelectedRows.push_back(m_nCurRow); m_aSelectedRows.push_back(m_nCurRow);
invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); invalidateRow( m_nCurRow );
selectionChanged = true; selectionChanged = true;
bSuccess = true; bSuccess = true;
} }
...@@ -1626,14 +1617,10 @@ namespace svt { namespace table ...@@ -1626,14 +1617,10 @@ namespace svt { namespace table
//and select the current row //and select the current row
if(m_nAnchor==-1) if(m_nAnchor==-1)
{ {
for(std::vector<RowPos>::iterator it=m_aSelectedRows.begin(); invalidateSelectedRows();
it!=m_aSelectedRows.end();++it)
{
invalidateSelectedRegion(*it, *it, rCells);
}
m_aSelectedRows.clear(); m_aSelectedRows.clear();
m_aSelectedRows.push_back(m_nCurRow); m_aSelectedRows.push_back(m_nCurRow);
invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); invalidateRow( m_nCurRow );
} }
else else
{ {
...@@ -1651,12 +1638,12 @@ namespace svt { namespace table ...@@ -1651,12 +1638,12 @@ namespace svt { namespace table
if(nextRow>-1 && m_aSelectedRows[nextRow] == m_nCurRow) if(nextRow>-1 && m_aSelectedRows[nextRow] == m_nCurRow)
{ {
m_aSelectedRows.erase(m_aSelectedRows.begin()+prevRow); m_aSelectedRows.erase(m_aSelectedRows.begin()+prevRow);
invalidateSelectedRegion(m_nCurRow+1, m_nCurRow+1, rCells); invalidateRow( m_nCurRow + 1 );
} }
else else
{ {
m_aSelectedRows.push_back(m_nCurRow); m_aSelectedRows.push_back(m_nCurRow);
invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); invalidateRow( m_nCurRow );
} }
} }
else else
...@@ -1666,7 +1653,7 @@ namespace svt { namespace table ...@@ -1666,7 +1653,7 @@ namespace svt { namespace table
m_aSelectedRows.push_back(m_nCurRow); m_aSelectedRows.push_back(m_nCurRow);
m_nCurRow--; m_nCurRow--;
m_aSelectedRows.push_back(m_nCurRow); m_aSelectedRows.push_back(m_nCurRow);
invalidateSelectedRegion(m_nCurRow+1, m_nCurRow, rCells); invalidateSelectedRegion( m_nCurRow+1, m_nCurRow );
} }
} }
} }
...@@ -1681,12 +1668,12 @@ namespace svt { namespace table ...@@ -1681,12 +1668,12 @@ namespace svt { namespace table
m_aSelectedRows.push_back(m_nCurRow); m_aSelectedRows.push_back(m_nCurRow);
m_nCurRow--; m_nCurRow--;
m_aSelectedRows.push_back(m_nCurRow); m_aSelectedRows.push_back(m_nCurRow);
invalidateSelectedRegion(m_nCurRow+1, m_nCurRow, rCells); invalidateSelectedRegion( m_nCurRow+1, m_nCurRow );
} }
else else
{ {
m_aSelectedRows.push_back(m_nCurRow); m_aSelectedRows.push_back(m_nCurRow);
invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); invalidateRow( m_nCurRow );
} }
} }
m_pSelEngine->SetAnchor(sal_True); m_pSelEngine->SetAnchor(sal_True);
...@@ -1713,14 +1700,10 @@ namespace svt { namespace table ...@@ -1713,14 +1700,10 @@ namespace svt { namespace table
//and select the current row //and select the current row
if(m_nAnchor==-1) if(m_nAnchor==-1)
{ {
for(std::vector<RowPos>::iterator it=m_aSelectedRows.begin(); invalidateSelectedRows();
it!=m_aSelectedRows.end();++it)
{
invalidateSelectedRegion(*it, *it, rCells);
}
m_aSelectedRows.clear(); m_aSelectedRows.clear();
m_aSelectedRows.push_back(m_nCurRow); m_aSelectedRows.push_back(m_nCurRow);
invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); invalidateRow( m_nCurRow );
} }
else else
{ {
...@@ -1738,12 +1721,12 @@ namespace svt { namespace table ...@@ -1738,12 +1721,12 @@ namespace svt { namespace table
if(nextRow>-1 && m_aSelectedRows[nextRow] == m_nCurRow) if(nextRow>-1 && m_aSelectedRows[nextRow] == m_nCurRow)
{ {
m_aSelectedRows.erase(m_aSelectedRows.begin()+prevRow); m_aSelectedRows.erase(m_aSelectedRows.begin()+prevRow);
invalidateSelectedRegion(m_nCurRow-1, m_nCurRow-1, rCells); invalidateRow( m_nCurRow - 1 );
} }
else else
{ {
m_aSelectedRows.push_back(m_nCurRow); m_aSelectedRows.push_back(m_nCurRow);
invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); invalidateRow( m_nCurRow );
} }
} }
else else
...@@ -1753,7 +1736,7 @@ namespace svt { namespace table ...@@ -1753,7 +1736,7 @@ namespace svt { namespace table
m_aSelectedRows.push_back(m_nCurRow); m_aSelectedRows.push_back(m_nCurRow);
m_nCurRow++; m_nCurRow++;
m_aSelectedRows.push_back(m_nCurRow); m_aSelectedRows.push_back(m_nCurRow);
invalidateSelectedRegion(m_nCurRow-1, m_nCurRow, rCells); invalidateSelectedRegion( m_nCurRow-1, m_nCurRow );
} }
} }
} }
...@@ -1766,12 +1749,12 @@ namespace svt { namespace table ...@@ -1766,12 +1749,12 @@ namespace svt { namespace table
m_aSelectedRows.push_back(m_nCurRow); m_aSelectedRows.push_back(m_nCurRow);
m_nCurRow++; m_nCurRow++;
m_aSelectedRows.push_back(m_nCurRow); m_aSelectedRows.push_back(m_nCurRow);
invalidateSelectedRegion(m_nCurRow-1, m_nCurRow, rCells); invalidateSelectedRegion( m_nCurRow-1, m_nCurRow );
} }
else else
{ {
m_aSelectedRows.push_back(m_nCurRow); m_aSelectedRows.push_back(m_nCurRow);
invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); invalidateRow( m_nCurRow );
} }
} }
m_pSelEngine->SetAnchor(sal_True); m_pSelEngine->SetAnchor(sal_True);
...@@ -1793,7 +1776,7 @@ namespace svt { namespace table ...@@ -1793,7 +1776,7 @@ namespace svt { namespace table
{ {
//select the region between the current and the upper row //select the region between the current and the upper row
RowPos iter = m_nCurRow; RowPos iter = m_nCurRow;
invalidateSelectedRegion(m_nCurRow, 0, rCells); invalidateSelectedRegion( m_nCurRow, 0 );
//put the rows in vector //put the rows in vector
while(iter>=0) while(iter>=0)
{ {
...@@ -1819,7 +1802,7 @@ namespace svt { namespace table ...@@ -1819,7 +1802,7 @@ namespace svt { namespace table
return bSuccess = false; return bSuccess = false;
//select the region between the current and the last row //select the region between the current and the last row
RowPos iter = m_nCurRow; RowPos iter = m_nCurRow;
invalidateSelectedRegion(m_nCurRow, m_nRowCount-1, rCells); invalidateSelectedRegion( m_nCurRow, m_nRowCount-1 );
//put the rows in the vector //put the rows in the vector
while(iter<=m_nRowCount) while(iter<=m_nRowCount)
{ {
...@@ -2016,48 +1999,59 @@ namespace svt { namespace table ...@@ -2016,48 +1999,59 @@ namespace svt { namespace table
} }
//------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------
void TableControl_Impl::invalidateSelectedRegion(RowPos _nPrevRow, RowPos _nCurRow, Rectangle& _rCellRect) void TableControl_Impl::invalidateSelectedRegion( RowPos _nPrevRow, RowPos _nCurRow )
{ {
DBG_CHECK_ME(); DBG_CHECK_ME();
//get the visible area of the table control and set the Left and right border of the region to be repainted // get the visible area of the table control and set the Left and right border of the region to be repainted
Rectangle const aAllCells( impl_getAllVisibleCellsArea() ); Rectangle const aAllCells( impl_getAllVisibleCellsArea() );
_rCellRect.Left() = aAllCells.Left();
_rCellRect.Right() = aAllCells.Right(); Rectangle aInvalidateRect;
//if only one row is selected aInvalidateRect.Left() = aAllCells.Left();
if(_nPrevRow == _nCurRow) aInvalidateRect.Right() = aAllCells.Right();
// if only one row is selected
if ( _nPrevRow == _nCurRow )
{ {
Rectangle aCellRect; Rectangle aCellRect;
impl_getCellRect( m_nCurColumn, _nCurRow, aCellRect ); impl_getCellRect( m_nCurColumn, _nCurRow, aCellRect );
_rCellRect.Top() = aCellRect.Top(); aInvalidateRect.Top() = aCellRect.Top();
_rCellRect.Bottom() = aCellRect.Bottom(); aInvalidateRect.Bottom() = aCellRect.Bottom();
} }
//if the region is above the current row //if the region is above the current row
else if(_nPrevRow < _nCurRow ) else if(_nPrevRow < _nCurRow )
{ {
Rectangle aCellRect; Rectangle aCellRect;
impl_getCellRect( m_nCurColumn, _nPrevRow, aCellRect ); impl_getCellRect( m_nCurColumn, _nPrevRow, aCellRect );
_rCellRect.Top() = aCellRect.Top(); aInvalidateRect.Top() = aCellRect.Top();
impl_getCellRect( m_nCurColumn, _nCurRow, aCellRect ); impl_getCellRect( m_nCurColumn, _nCurRow, aCellRect );
_rCellRect.Bottom() = aCellRect.Bottom(); aInvalidateRect.Bottom() = aCellRect.Bottom();
} }
//if the region is beneath the current row //if the region is beneath the current row
else else
{ {
Rectangle aCellRect; Rectangle aCellRect;
impl_getCellRect( m_nCurColumn, _nCurRow, aCellRect ); impl_getCellRect( m_nCurColumn, _nCurRow, aCellRect );
_rCellRect.Top() = aCellRect.Top(); aInvalidateRect.Top() = aCellRect.Top();
impl_getCellRect( m_nCurColumn, _nPrevRow, aCellRect ); impl_getCellRect( m_nCurColumn, _nPrevRow, aCellRect );
_rCellRect.Bottom() = aCellRect.Bottom(); aInvalidateRect.Bottom() = aCellRect.Bottom();
} }
m_pDataWindow->Invalidate(_rCellRect); m_pDataWindow->Invalidate( aInvalidateRect );
} }
//------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------
void TableControl_Impl::invalidateRowRange( RowPos const i_firstRow, RowPos const i_lastRow ) void TableControl_Impl::invalidateSelectedRows()
{
for ( ::std::vector< RowPos >::iterator selRow = m_aSelectedRows.begin();
selRow != m_aSelectedRows.end();
++selRow
)
{ {
if ( m_nCursorHidden == 2 ) invalidateRow( *selRow );
// WTF? what kind of hack is this? }
--m_nCursorHidden; }
//------------------------------------------------------------------------------------------------------------------
void TableControl_Impl::invalidateRowRange( RowPos const i_firstRow, RowPos const i_lastRow )
{
RowPos const firstRow = i_firstRow < m_nTopRow ? m_nTopRow : i_firstRow; RowPos const firstRow = i_firstRow < m_nTopRow ? m_nTopRow : i_firstRow;
RowPos const lastVisibleRow = m_nTopRow + impl_getVisibleRows( true ) - 1; RowPos const lastVisibleRow = m_nTopRow + impl_getVisibleRows( true ) - 1;
RowPos const lastRow = ( ( i_lastRow == ROW_INVALID ) || ( i_lastRow > lastVisibleRow ) ) ? lastVisibleRow : i_lastRow; RowPos const lastRow = ( ( i_lastRow == ROW_INVALID ) || ( i_lastRow > lastVisibleRow ) ) ? lastVisibleRow : i_lastRow;
...@@ -2666,8 +2660,7 @@ namespace svt { namespace table ...@@ -2666,8 +2660,7 @@ namespace svt { namespace table
} }
m_pTableControl->setAnchor( m_pTableControl->getAnchor() - 1 ); m_pTableControl->setAnchor( m_pTableControl->getAnchor() - 1 );
} }
Rectangle aCellRect; m_pTableControl->invalidateSelectedRegion( m_pTableControl->getCurRow(), newRow );
m_pTableControl->invalidateSelectedRegion( m_pTableControl->getCurRow(), newRow, aCellRect );
bHandled = sal_True; bHandled = sal_True;
} }
//no region selected //no region selected
...@@ -2690,8 +2683,7 @@ namespace svt { namespace table ...@@ -2690,8 +2683,7 @@ namespace svt { namespace table
if ( m_pTableControl->getSelectedRowCount() > 1 && m_pTableControl->getSelEngine()->GetSelectionMode() != SINGLE_SELECTION ) if ( m_pTableControl->getSelectedRowCount() > 1 && m_pTableControl->getSelEngine()->GetSelectionMode() != SINGLE_SELECTION )
m_pTableControl->getSelEngine()->AddAlways(sal_True); m_pTableControl->getSelEngine()->AddAlways(sal_True);
Rectangle aCellRect; m_pTableControl->invalidateRow( newRow );
m_pTableControl->invalidateSelectedRegion( newRow, newRow, aCellRect );
bHandled = sal_True; bHandled = sal_True;
} }
m_pTableControl->goTo( newCol, newRow ); m_pTableControl->goTo( newCol, newRow );
...@@ -2716,8 +2708,7 @@ namespace svt { namespace table ...@@ -2716,8 +2708,7 @@ namespace svt { namespace table
void TableFunctionSet::DeselectAtPoint( const Point& rPoint ) void TableFunctionSet::DeselectAtPoint( const Point& rPoint )
{ {
(void)rPoint; (void)rPoint;
Rectangle aCellRange; m_pTableControl->invalidateRow( m_nCurrentRow );
m_pTableControl->invalidateSelectedRegion( m_nCurrentRow, m_nCurrentRow, aCellRange );
m_pTableControl->markRowAsDeselected( m_nCurrentRow ); m_pTableControl->markRowAsDeselected( m_nCurrentRow );
} }
...@@ -2726,11 +2717,10 @@ namespace svt { namespace table ...@@ -2726,11 +2717,10 @@ namespace svt { namespace table
{ {
if ( m_pTableControl->hasRowSelection() ) if ( m_pTableControl->hasRowSelection() )
{ {
Rectangle aCellRange;
for ( size_t i=0; i<m_pTableControl->getSelectedRowCount(); ++i ) for ( size_t i=0; i<m_pTableControl->getSelectedRowCount(); ++i )
{ {
RowPos const rowIndex = m_pTableControl->getSelectedRowIndex(i); RowPos const rowIndex = m_pTableControl->getSelectedRowIndex(i);
m_pTableControl->invalidateSelectedRegion( rowIndex, rowIndex, aCellRange ); m_pTableControl->invalidateRow( rowIndex );
} }
m_pTableControl->markAllRowsAsDeselected(); m_pTableControl->markAllRowsAsDeselected();
......
...@@ -223,10 +223,10 @@ namespace svt { namespace table ...@@ -223,10 +223,10 @@ namespace svt { namespace table
/** returns the position of the current row in the selection vector */ /** returns the position of the current row in the selection vector */
int getRowSelectedNumber(const ::std::vector<RowPos>& selectedRows, RowPos current); int getRowSelectedNumber(const ::std::vector<RowPos>& selectedRows, RowPos current);
/** _rCellRect contains the region, which should be invalidate after some action e.g. selecting row*/ /** ??? */
void invalidateSelectedRegion(RowPos _nPrevRow, RowPos _nCurRow, Rectangle& _rCellRect ); void invalidateSelectedRegion( RowPos _nPrevRow, RowPos _nCurRow );
/** invalidates the part of the data window which is covered by the given row /** invalidates the part of the data window which is covered by the given rows
@param i_firstRow @param i_firstRow
the index of the first row to include in the invalidation the index of the first row to include in the invalidation
@param i_lastRow @param i_lastRow
...@@ -235,6 +235,14 @@ namespace svt { namespace table ...@@ -235,6 +235,14 @@ namespace svt { namespace table
*/ */
void invalidateRowRange( RowPos const i_firstRow, RowPos const i_lastRow ); void invalidateRowRange( RowPos const i_firstRow, RowPos const i_lastRow );
/** invalidates the part of the data window which is covered by the given row
*/
void invalidateRow( RowPos const i_row ) { invalidateRowRange( i_row, i_row ); }
/** invalidates all selected rows
*/
void invalidateSelectedRows();
void checkCursorPosition(); void checkCursorPosition();
bool hasRowSelection() const { return !m_aSelectedRows.empty(); } bool hasRowSelection() const { return !m_aSelectedRows.empty(); }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment