Kaydet (Commit) f4147a39 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

refactor TableControl to use RenderContext

Change-Id: I4a84cdc8517b69b28fbb8521d0593ae5ed4c3a79
üst f54212fb
...@@ -36,22 +36,20 @@ ...@@ -36,22 +36,20 @@
namespace svt { namespace table namespace svt { namespace table
{ {
using ::css::uno::Any;
using ::css::uno::Reference;
using ::com::sun::star::uno::Any; using ::css::uno::UNO_QUERY;
using ::com::sun::star::uno::Reference; using ::css::uno::XInterface;
using ::com::sun::star::uno::UNO_QUERY; using ::css::uno::TypeClass_INTERFACE;
using ::com::sun::star::uno::XInterface; using ::css::graphic::XGraphic;
using ::com::sun::star::uno::TypeClass_INTERFACE; using ::css::style::HorizontalAlignment;
using ::com::sun::star::graphic::XGraphic; using ::css::style::HorizontalAlignment_LEFT;
using ::com::sun::star::style::HorizontalAlignment; using ::css::style::HorizontalAlignment_CENTER;
using ::com::sun::star::style::HorizontalAlignment_LEFT; using ::css::style::HorizontalAlignment_RIGHT;
using ::com::sun::star::style::HorizontalAlignment_CENTER; using ::css::style::VerticalAlignment;
using ::com::sun::star::style::HorizontalAlignment_RIGHT; using ::css::style::VerticalAlignment_TOP;
using ::com::sun::star::style::VerticalAlignment; using ::css::style::VerticalAlignment_MIDDLE;
using ::com::sun::star::style::VerticalAlignment_TOP; using ::css::style::VerticalAlignment_BOTTOM;
using ::com::sun::star::style::VerticalAlignment_MIDDLE;
using ::com::sun::star::style::VerticalAlignment_BOTTOM;
//= CachedSortIndicator //= CachedSortIndicator
...@@ -60,26 +58,26 @@ namespace svt { namespace table ...@@ -60,26 +58,26 @@ namespace svt { namespace table
{ {
public: public:
CachedSortIndicator() CachedSortIndicator()
:m_lastHeaderHeight( 0 ) : m_lastHeaderHeight( 0 )
,m_lastArrowColor( COL_TRANSPARENT ) , m_lastArrowColor( COL_TRANSPARENT )
{ {
} }
BitmapEx const & getBitmapFor( OutputDevice const & i_device, long const i_headerHeight, StyleSettings const & i_style, bool const i_sortAscending ); BitmapEx const & getBitmapFor(OutputDevice const & i_device, long const i_headerHeight,
StyleSettings const & i_style, bool const i_sortAscending);
private: private:
long m_lastHeaderHeight; long m_lastHeaderHeight;
Color m_lastArrowColor; Color m_lastArrowColor;
BitmapEx m_sortAscending; BitmapEx m_sortAscending;
BitmapEx m_sortDescending; BitmapEx m_sortDescending;
}; };
BitmapEx const & CachedSortIndicator::getBitmapFor(vcl::RenderContext const& i_device, long const i_headerHeight,
BitmapEx const & CachedSortIndicator::getBitmapFor( OutputDevice const & i_device, long const i_headerHeight,
StyleSettings const & i_style, bool const i_sortAscending ) StyleSettings const & i_style, bool const i_sortAscending )
{ {
BitmapEx & rBitmap( i_sortAscending ? m_sortAscending : m_sortDescending ); BitmapEx& rBitmap(i_sortAscending ? m_sortAscending : m_sortDescending);
if ( !rBitmap || ( i_headerHeight != m_lastHeaderHeight ) || ( i_style.GetActiveColor() != m_lastArrowColor ) ) if (!rBitmap || (i_headerHeight != m_lastHeaderHeight) || (i_style.GetActiveColor() != m_lastArrowColor))
{ {
long const nSortIndicatorWidth = 2 * i_headerHeight / 3; long const nSortIndicatorWidth = 2 * i_headerHeight / 3;
long const nSortIndicatorHeight = 2 * nSortIndicatorWidth / 3; long const nSortIndicatorHeight = 2 * nSortIndicatorWidth / 3;
...@@ -89,14 +87,12 @@ namespace svt { namespace table ...@@ -89,14 +87,12 @@ namespace svt { namespace table
ScopedVclPtrInstance< VirtualDevice > aDevice( i_device, 0, 0 ); ScopedVclPtrInstance< VirtualDevice > aDevice( i_device, 0, 0 );
aDevice->SetOutputSizePixel( aBitmapSize ); aDevice->SetOutputSizePixel( aBitmapSize );
DecorationView aDecoView( aDevice.get() ); DecorationView aDecoView(aDevice.get());
aDecoView.DrawSymbol( aDecoView.DrawSymbol(Rectangle(aBitmapPos, aBitmapSize),
Rectangle( aBitmapPos, aBitmapSize ), i_sortAscending ? SymbolType::SPIN_UP : SymbolType::SPIN_DOWN,
i_sortAscending ? SymbolType::SPIN_UP : SymbolType::SPIN_DOWN, i_style.GetActiveColor());
i_style.GetActiveColor()
);
rBitmap = aDevice->GetBitmapEx( aBitmapPos, aBitmapSize ); rBitmap = aDevice->GetBitmapEx(aBitmapPos, aBitmapSize);
m_lastHeaderHeight = i_headerHeight; m_lastHeaderHeight = i_headerHeight;
m_lastArrowColor = i_style.GetActiveColor(); m_lastArrowColor = i_style.GetActiveColor();
} }
...@@ -115,11 +111,11 @@ namespace svt { namespace table ...@@ -115,11 +111,11 @@ namespace svt { namespace table
CellValueConversion aStringConverter; CellValueConversion aStringConverter;
GridTableRenderer_Impl( ITableModel& _rModel ) GridTableRenderer_Impl( ITableModel& _rModel )
:rModel( _rModel ) : rModel( _rModel )
,nCurrentRow( ROW_INVALID ) , nCurrentRow( ROW_INVALID )
,bUseGridLines( true ) , bUseGridLines( true )
,aSortIndicator( ) , aSortIndicator( )
,aStringConverter() , aStringConverter()
{ {
} }
}; };
...@@ -205,51 +201,48 @@ namespace svt { namespace table ...@@ -205,51 +201,48 @@ namespace svt { namespace table
namespace namespace
{ {
Color lcl_getEffectiveColor( Color lcl_getEffectiveColor(boost::optional<Color> const& i_modelColor,
::boost::optional< ::Color > const & i_modelColor, StyleSettings const& i_styleSettings,
StyleSettings const & i_styleSettings, Color const& (StyleSettings::*i_getDefaultColor) () const)
::Color const & ( StyleSettings::*i_getDefaultColor ) () const
)
{ {
if ( !!i_modelColor ) if (!!i_modelColor)
return *i_modelColor; return *i_modelColor;
return ( i_styleSettings.*i_getDefaultColor )(); return (i_styleSettings.*i_getDefaultColor)();
} }
} }
void GridTableRenderer::PaintHeaderArea( void GridTableRenderer::PaintHeaderArea(vcl::RenderContext& rRenderContext, const Rectangle& _rArea,
OutputDevice& _rDevice, const Rectangle& _rArea, bool _bIsColHeaderArea, bool _bIsRowHeaderArea, bool _bIsColHeaderArea, bool _bIsRowHeaderArea, const StyleSettings& _rStyle)
const StyleSettings& _rStyle )
{ {
OSL_PRECOND( _bIsColHeaderArea || _bIsRowHeaderArea, OSL_PRECOND(_bIsColHeaderArea || _bIsRowHeaderArea, "GridTableRenderer::PaintHeaderArea: invalid area flags!");
"GridTableRenderer::PaintHeaderArea: invalid area flags!" );
_rDevice.Push( PushFlags::FILLCOLOR | PushFlags::LINECOLOR ); rRenderContext.Push(PushFlags::FILLCOLOR | PushFlags::LINECOLOR);
Color const background = lcl_getEffectiveColor( m_pImpl->rModel.getHeaderBackgroundColor(), _rStyle, &StyleSettings::GetDialogColor ); Color const background = lcl_getEffectiveColor(m_pImpl->rModel.getHeaderBackgroundColor(),
_rDevice.SetFillColor( background ); _rStyle, &StyleSettings::GetDialogColor);
rRenderContext.SetFillColor(background);
_rDevice.SetLineColor(); rRenderContext.SetLineColor();
_rDevice.DrawRect( _rArea ); rRenderContext.DrawRect(_rArea);
// delimiter lines at bottom/right // delimiter lines at bottom/right
::boost::optional< ::Color > aLineColor( m_pImpl->rModel.getLineColor() ); boost::optional<Color> aLineColor(m_pImpl->rModel.getLineColor());
::Color const lineColor = !aLineColor ? _rStyle.GetSeparatorColor() : *aLineColor; Color const lineColor = !aLineColor ? _rStyle.GetSeparatorColor() : *aLineColor;
_rDevice.SetLineColor( lineColor ); rRenderContext.SetLineColor(lineColor);
_rDevice.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() ); rRenderContext.DrawLine(_rArea.BottomLeft(), _rArea.BottomRight());
_rDevice.DrawLine( _rArea.BottomRight(), _rArea.TopRight() ); rRenderContext.DrawLine(_rArea.BottomRight(), _rArea.TopRight());
_rDevice.Pop(); rRenderContext.Pop();
(void)_bIsColHeaderArea; (void)_bIsColHeaderArea;
(void)_bIsRowHeaderArea; (void)_bIsRowHeaderArea;
} }
void GridTableRenderer::PaintColumnHeader( ColPos _nCol, bool _bActive, bool _bSelected, void GridTableRenderer::PaintColumnHeader(ColPos _nCol, bool _bActive, bool _bSelected, vcl::RenderContext& rRenderContext,
OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle ) const Rectangle& _rArea, const StyleSettings& _rStyle)
{ {
_rDevice.Push( PushFlags::LINECOLOR); rRenderContext.Push(PushFlags::LINECOLOR);
OUString sHeaderText; OUString sHeaderText;
PColumnModel const pColumn = m_pImpl->rModel.getColumnModel( _nCol ); PColumnModel const pColumn = m_pImpl->rModel.getColumnModel( _nCol );
...@@ -257,20 +250,20 @@ namespace svt { namespace table ...@@ -257,20 +250,20 @@ namespace svt { namespace table
if ( !!pColumn ) if ( !!pColumn )
sHeaderText = pColumn->getName(); sHeaderText = pColumn->getName();
::Color const textColor = lcl_getEffectiveColor( m_pImpl->rModel.getTextColor(), _rStyle, &StyleSettings::GetFieldTextColor ); Color const textColor = lcl_getEffectiveColor( m_pImpl->rModel.getTextColor(), _rStyle, &StyleSettings::GetFieldTextColor );
_rDevice.SetTextColor( textColor ); rRenderContext.SetTextColor(textColor);
Rectangle const aTextRect( lcl_getTextRenderingArea( lcl_getContentArea( *m_pImpl, _rArea ) ) ); Rectangle const aTextRect( lcl_getTextRenderingArea( lcl_getContentArea( *m_pImpl, _rArea ) ) );
sal_uLong nDrawTextFlags = lcl_getAlignmentTextDrawFlags( *m_pImpl, _nCol ) | TEXT_DRAW_CLIP; sal_uLong nDrawTextFlags = lcl_getAlignmentTextDrawFlags( *m_pImpl, _nCol ) | TEXT_DRAW_CLIP;
if ( !m_pImpl->rModel.isEnabled() ) if (!m_pImpl->rModel.isEnabled())
nDrawTextFlags |= TEXT_DRAW_DISABLE; nDrawTextFlags |= TEXT_DRAW_DISABLE;
_rDevice.DrawText( aTextRect, sHeaderText, nDrawTextFlags ); rRenderContext.DrawText( aTextRect, sHeaderText, nDrawTextFlags );
::boost::optional< ::Color > const aLineColor( m_pImpl->rModel.getLineColor() ); boost::optional<Color> const aLineColor( m_pImpl->rModel.getLineColor() );
::Color const lineColor = !aLineColor ? _rStyle.GetSeparatorColor() : *aLineColor; Color const lineColor = !aLineColor ? _rStyle.GetSeparatorColor() : *aLineColor;
_rDevice.SetLineColor( lineColor ); rRenderContext.SetLineColor( lineColor );
_rDevice.DrawLine( _rArea.BottomRight(), _rArea.TopRight()); rRenderContext.DrawLine( _rArea.BottomRight(), _rArea.TopRight());
_rDevice.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() ); rRenderContext.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() );
// draw sort indicator if the model data is sorted by the given column // draw sort indicator if the model data is sorted by the given column
ITableDataSort const * pSortAdapter = m_pImpl->rModel.getSortAdapter(); ITableDataSort const * pSortAdapter = m_pImpl->rModel.getSortAdapter();
...@@ -280,8 +273,8 @@ namespace svt { namespace table ...@@ -280,8 +273,8 @@ namespace svt { namespace table
if ( aCurrentSortOrder.nColumnPos == _nCol ) if ( aCurrentSortOrder.nColumnPos == _nCol )
{ {
long const nHeaderHeight( _rArea.GetHeight() ); long const nHeaderHeight( _rArea.GetHeight() );
BitmapEx const aIndicatorBitmap = m_pImpl->aSortIndicator.getBitmapFor( _rDevice, nHeaderHeight, _rStyle, BitmapEx const aIndicatorBitmap = m_pImpl->aSortIndicator.getBitmapFor(rRenderContext, nHeaderHeight, _rStyle,
aCurrentSortOrder.eSortDirection == ColumnSortAscending ); aCurrentSortOrder.eSortDirection == ColumnSortAscending);
Size const aBitmapSize( aIndicatorBitmap.GetSizePixel() ); Size const aBitmapSize( aIndicatorBitmap.GetSizePixel() );
long const nSortIndicatorPaddingX = 2; long const nSortIndicatorPaddingX = 2;
long const nSortIndicatorPaddingY = ( nHeaderHeight - aBitmapSize.Height() ) / 2; long const nSortIndicatorPaddingY = ( nHeaderHeight - aBitmapSize.Height() ) / 2;
...@@ -289,22 +282,18 @@ namespace svt { namespace table ...@@ -289,22 +282,18 @@ namespace svt { namespace table
if ( ( nDrawTextFlags & TEXT_DRAW_RIGHT ) != 0 ) if ( ( nDrawTextFlags & TEXT_DRAW_RIGHT ) != 0 )
{ {
// text is right aligned => draw the sort indicator at the left hand side // text is right aligned => draw the sort indicator at the left hand side
_rDevice.DrawBitmapEx( rRenderContext.DrawBitmapEx(Point(_rArea.Left() + nSortIndicatorPaddingX, _rArea.Top() + nSortIndicatorPaddingY),
Point( _rArea.Left() + nSortIndicatorPaddingX, _rArea.Top() + nSortIndicatorPaddingY ), aIndicatorBitmap);
aIndicatorBitmap
);
} }
else else
{ {
// text is left-aligned or centered => draw the sort indicator at the right hand side // text is left-aligned or centered => draw the sort indicator at the right hand side
_rDevice.DrawBitmapEx( rRenderContext.DrawBitmapEx(Point(_rArea.Right() - nSortIndicatorPaddingX - aBitmapSize.Width(), nSortIndicatorPaddingY),
Point( _rArea.Right() - nSortIndicatorPaddingX - aBitmapSize.Width(), nSortIndicatorPaddingY ), aIndicatorBitmap);
aIndicatorBitmap
);
} }
} }
_rDevice.Pop(); rRenderContext.Pop();
(void)_bActive; (void)_bActive;
// no special painting for the active column at the moment // no special painting for the active column at the moment
...@@ -314,38 +303,38 @@ namespace svt { namespace table ...@@ -314,38 +303,38 @@ namespace svt { namespace table
} }
void GridTableRenderer::PrepareRow( RowPos _nRow, bool i_hasControlFocus, bool _bSelected, void GridTableRenderer::PrepareRow(RowPos _nRow, bool i_hasControlFocus, bool _bSelected, vcl::RenderContext& rRenderContext,
OutputDevice& _rDevice, const Rectangle& _rRowArea, const StyleSettings& _rStyle ) 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
m_pImpl->nCurrentRow = _nRow; m_pImpl->nCurrentRow = _nRow;
_rDevice.Push( PushFlags::FILLCOLOR | PushFlags::LINECOLOR); rRenderContext.Push(PushFlags::FILLCOLOR | PushFlags::LINECOLOR);
::Color backgroundColor = _rStyle.GetFieldColor(); Color backgroundColor = _rStyle.GetFieldColor();
::boost::optional< ::Color > const aLineColor( m_pImpl->rModel.getLineColor() ); boost::optional<Color> const aLineColor( m_pImpl->rModel.getLineColor() );
::Color lineColor = !aLineColor ? _rStyle.GetSeparatorColor() : *aLineColor; Color lineColor = !aLineColor ? _rStyle.GetSeparatorColor() : *aLineColor;
::Color const activeSelectionBackColor = Color const activeSelectionBackColor = lcl_getEffectiveColor(m_pImpl->rModel.getActiveSelectionBackColor(),
lcl_getEffectiveColor( m_pImpl->rModel.getActiveSelectionBackColor(), _rStyle, &StyleSettings::GetHighlightColor ); _rStyle, &StyleSettings::GetHighlightColor);
if ( _bSelected ) if (_bSelected)
{ {
// selected rows use the background color from the style // selected rows use the background color from the style
backgroundColor = i_hasControlFocus backgroundColor = i_hasControlFocus
? activeSelectionBackColor ? activeSelectionBackColor
: lcl_getEffectiveColor( m_pImpl->rModel.getInactiveSelectionBackColor(), _rStyle, &StyleSettings::GetDeactiveColor ); : lcl_getEffectiveColor(m_pImpl->rModel.getInactiveSelectionBackColor(), _rStyle, &StyleSettings::GetDeactiveColor);
if ( !aLineColor ) if (!aLineColor)
lineColor = backgroundColor; lineColor = backgroundColor;
} }
else else
{ {
::boost::optional< ::std::vector< ::Color > > aRowColors = m_pImpl->rModel.getRowBackgroundColors(); boost::optional< std::vector<Color> > aRowColors = m_pImpl->rModel.getRowBackgroundColors();
if ( !aRowColors ) if (!aRowColors)
{ {
// use alternating default colors // use alternating default colors
Color const fieldColor = _rStyle.GetFieldColor(); Color const fieldColor = _rStyle.GetFieldColor();
if ( _rStyle.GetHighContrastMode() || ( ( m_pImpl->nCurrentRow % 2 ) == 0 ) ) if (_rStyle.GetHighContrastMode() || ((m_pImpl->nCurrentRow % 2) == 0))
{ {
backgroundColor = fieldColor; backgroundColor = fieldColor;
} }
...@@ -360,55 +349,53 @@ namespace svt { namespace table ...@@ -360,55 +349,53 @@ namespace svt { namespace table
} }
else else
{ {
if ( aRowColors->empty() ) if (aRowColors->empty())
{ {
// all colors have the same background color // all colors have the same background color
backgroundColor = _rStyle.GetFieldColor(); backgroundColor = _rStyle.GetFieldColor();
} }
else else
{ {
backgroundColor = aRowColors->at( m_pImpl->nCurrentRow % aRowColors->size() ); backgroundColor = aRowColors->at(m_pImpl->nCurrentRow % aRowColors->size());
} }
} }
} }
//m_pImpl->bUseGridLines ? _rDevice.SetLineColor( lineColor ) : _rDevice.SetLineColor(); rRenderContext.SetLineColor();
_rDevice.SetLineColor(); rRenderContext.SetFillColor(backgroundColor);
_rDevice.SetFillColor( backgroundColor ); rRenderContext.DrawRect(_rRowArea);
_rDevice.DrawRect( _rRowArea );
_rDevice.Pop(); rRenderContext.Pop();
} }
void GridTableRenderer::PaintRowHeader( bool i_hasControlFocus, bool _bSelected, OutputDevice& _rDevice, const Rectangle& _rArea, void GridTableRenderer::PaintRowHeader(bool /*i_hasControlFocus*/, bool /*_bSelected*/, vcl::RenderContext& rRenderContext,
const StyleSettings& _rStyle ) const Rectangle& _rArea, const StyleSettings& _rStyle)
{ {
_rDevice.Push( PushFlags::LINECOLOR | PushFlags::TEXTCOLOR ); rRenderContext.Push( PushFlags::LINECOLOR | PushFlags::TEXTCOLOR );
::boost::optional< ::Color > const aLineColor( m_pImpl->rModel.getLineColor() ); boost::optional<Color> const aLineColor( m_pImpl->rModel.getLineColor() );
::Color const lineColor = !aLineColor ? _rStyle.GetSeparatorColor() : *aLineColor; Color const lineColor = !aLineColor ? _rStyle.GetSeparatorColor() : *aLineColor;
_rDevice.SetLineColor( lineColor ); rRenderContext.SetLineColor(lineColor);
_rDevice.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() ); rRenderContext.DrawLine(_rArea.BottomLeft(), _rArea.BottomRight());
Any const rowHeading( m_pImpl->rModel.getRowHeading( m_pImpl->nCurrentRow ) ); Any const rowHeading( m_pImpl->rModel.getRowHeading( m_pImpl->nCurrentRow ) );
OUString const rowTitle( m_pImpl->aStringConverter.convertToString( rowHeading ) ); OUString const rowTitle( m_pImpl->aStringConverter.convertToString( rowHeading ) );
if ( !rowTitle.isEmpty() ) if (!rowTitle.isEmpty())
{ {
::Color const textColor = lcl_getEffectiveColor( m_pImpl->rModel.getHeaderTextColor(), _rStyle, &StyleSettings::GetFieldTextColor ); Color const textColor = lcl_getEffectiveColor(m_pImpl->rModel.getHeaderTextColor(),
_rDevice.SetTextColor( textColor ); _rStyle, &StyleSettings::GetFieldTextColor);
rRenderContext.SetTextColor(textColor);
Rectangle const aTextRect( lcl_getTextRenderingArea( lcl_getContentArea( *m_pImpl, _rArea ) ) ); Rectangle const aTextRect(lcl_getTextRenderingArea(lcl_getContentArea(*m_pImpl, _rArea)));
sal_uLong nDrawTextFlags = lcl_getAlignmentTextDrawFlags( *m_pImpl, 0 ) | TEXT_DRAW_CLIP; sal_uLong nDrawTextFlags = lcl_getAlignmentTextDrawFlags(*m_pImpl, 0) | TEXT_DRAW_CLIP;
if ( !m_pImpl->rModel.isEnabled() ) if (!m_pImpl->rModel.isEnabled())
nDrawTextFlags |= TEXT_DRAW_DISABLE; nDrawTextFlags |= TEXT_DRAW_DISABLE;
// TODO: is using the horizontal alignment of the 0'th column a good idea here? This is pretty ... arbitray .. // TODO: is using the horizontal alignment of the 0'th column a good idea here? This is pretty ... arbitray ..
_rDevice.DrawText( aTextRect, rowTitle, nDrawTextFlags ); rRenderContext.DrawText(aTextRect, rowTitle, nDrawTextFlags);
} }
(void)i_hasControlFocus; rRenderContext.Pop();
(void)_bSelected;
_rDevice.Pop();
} }
...@@ -434,14 +421,14 @@ namespace svt { namespace table ...@@ -434,14 +421,14 @@ namespace svt { namespace table
}; };
void GridTableRenderer::PaintCell( ColPos const i_column, bool _bSelected, bool i_hasControlFocus, void GridTableRenderer::PaintCell(ColPos const i_column, bool _bSelected, bool i_hasControlFocus,
OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle ) vcl::RenderContext& rRenderContext, const Rectangle& _rArea, const StyleSettings& _rStyle)
{ {
_rDevice.Push( PushFlags::LINECOLOR | PushFlags::FILLCOLOR ); rRenderContext.Push(PushFlags::LINECOLOR | PushFlags::FILLCOLOR);
Rectangle const aContentArea( lcl_getContentArea( *m_pImpl, _rArea ) ); Rectangle const aContentArea(lcl_getContentArea(*m_pImpl, _rArea));
CellRenderContext const aRenderContext( _rDevice, aContentArea, _rStyle, i_column, _bSelected, i_hasControlFocus ); CellRenderContext const aCellRenderContext(rRenderContext, aContentArea, _rStyle, i_column, _bSelected, i_hasControlFocus);
impl_paintCellContent( aRenderContext ); impl_paintCellContent(aCellRenderContext);
if ( m_pImpl->bUseGridLines ) if ( m_pImpl->bUseGridLines )
{ {
...@@ -456,12 +443,12 @@ namespace svt { namespace table ...@@ -456,12 +443,12 @@ namespace svt { namespace table
: lcl_getEffectiveColor( m_pImpl->rModel.getInactiveSelectionBackColor(), _rStyle, &StyleSettings::GetDeactiveColor ); : lcl_getEffectiveColor( m_pImpl->rModel.getInactiveSelectionBackColor(), _rStyle, &StyleSettings::GetDeactiveColor );
} }
_rDevice.SetLineColor( lineColor ); rRenderContext.SetLineColor( lineColor );
_rDevice.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() ); rRenderContext.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() );
_rDevice.DrawLine( _rArea.BottomRight(), _rArea.TopRight() ); rRenderContext.DrawLine( _rArea.BottomRight(), _rArea.TopRight() );
} }
_rDevice.Pop(); rRenderContext.Pop();
} }
......
...@@ -1197,124 +1197,103 @@ namespace svt { namespace table ...@@ -1197,124 +1197,103 @@ namespace svt { namespace table
} }
void TableControl_Impl::doPaintContent( const Rectangle& _rUpdateRect ) void TableControl_Impl::doPaintContent(vcl::RenderContext& rRenderContext, const Rectangle& _rUpdateRect)
{ {
if ( !getModel() ) if (!getModel())
return; return;
PTableRenderer pRenderer = getModel()->getRenderer(); PTableRenderer pRenderer = getModel()->getRenderer();
DBG_ASSERT( !!pRenderer, "TableDataWindow::doPaintContent: invalid renderer!" ); DBG_ASSERT(!!pRenderer, "TableDataWindow::doPaintContent: invalid renderer!");
if ( !pRenderer ) if (!pRenderer)
return; return;
// our current style settings, to be passed to the renderer // our current style settings, to be passed to the renderer
const StyleSettings& rStyle = m_rAntiImpl.GetSettings().GetStyleSettings(); const StyleSettings& rStyle = rRenderContext.GetSettings().GetStyleSettings();
m_nRowCount = m_pModel->getRowCount(); m_nRowCount = m_pModel->getRowCount();
// the area occupied by all (at least partially) visible cells, including // the area occupied by all (at least partially) visible cells, including
// headers // headers
Rectangle const aAllCellsWithHeaders( impl_getAllVisibleCellsArea() ); Rectangle const aAllCellsWithHeaders( impl_getAllVisibleCellsArea() );
// draw the header column area // draw the header column area
if ( m_pModel->hasColumnHeaders() ) if (m_pModel->hasColumnHeaders())
{ {
TableRowGeometry const aHeaderRow( *this, Rectangle( Point( 0, 0 ), TableRowGeometry const aHeaderRow(*this, Rectangle(Point(0, 0), aAllCellsWithHeaders.BottomRight()), ROW_COL_HEADERS);
aAllCellsWithHeaders.BottomRight() ), ROW_COL_HEADERS );
Rectangle const aColRect(aHeaderRow.getRect()); Rectangle const aColRect(aHeaderRow.getRect());
pRenderer->PaintHeaderArea( pRenderer->PaintHeaderArea(rRenderContext, aColRect, true, false, rStyle);
*m_pDataWindow, aColRect, true, false, rStyle
);
// Note that strictly, aHeaderRow.getRect() also contains the intersection between column // Note that strictly, aHeaderRow.getRect() also contains the intersection between column
// and row header area. However, below we go to paint this intersection, again, // and row header area. However, below we go to paint this intersection, again,
// so this hopefully doesn't hurt if we already paint it here. // so this hopefully doesn't hurt if we already paint it here.
for ( TableCellGeometry aCell( aHeaderRow, m_nLeftColumn ); for (TableCellGeometry aCell(aHeaderRow, m_nLeftColumn); aCell.isValid(); aCell.moveRight())
aCell.isValid();
aCell.moveRight()
)
{ {
if ( _rUpdateRect.GetIntersection( aCell.getRect() ).IsEmpty() ) if (_rUpdateRect.GetIntersection(aCell.getRect()).IsEmpty())
continue; continue;
bool isActiveColumn = ( aCell.getColumn() == getCurrentColumn() ); bool isActiveColumn = (aCell.getColumn() == getCurrentColumn());
bool isSelectedColumn = false; bool isSelectedColumn = false;
pRenderer->PaintColumnHeader( aCell.getColumn(), isActiveColumn, isSelectedColumn, pRenderer->PaintColumnHeader(aCell.getColumn(), isActiveColumn, isSelectedColumn, rRenderContext, aCell.getRect(), rStyle);
*m_pDataWindow, aCell.getRect(), rStyle );
} }
} }
// the area occupied by the row header, if any // the area occupied by the row header, if any
Rectangle aRowHeaderArea; Rectangle aRowHeaderArea;
if ( m_pModel->hasRowHeaders() ) if (m_pModel->hasRowHeaders())
{ {
aRowHeaderArea = aAllCellsWithHeaders; aRowHeaderArea = aAllCellsWithHeaders;
aRowHeaderArea.Right() = m_nRowHeaderWidthPixel - 1; aRowHeaderArea.Right() = m_nRowHeaderWidthPixel - 1;
TableSize const nVisibleRows = impl_getVisibleRows( true ); TableSize const nVisibleRows = impl_getVisibleRows(true);
TableSize nActualRows = nVisibleRows; TableSize nActualRows = nVisibleRows;
if ( m_nTopRow + nActualRows > m_nRowCount ) if (m_nTopRow + nActualRows > m_nRowCount)
nActualRows = m_nRowCount - m_nTopRow; nActualRows = m_nRowCount - m_nTopRow;
aRowHeaderArea.Bottom() = m_nColHeaderHeightPixel + m_nRowHeightPixel * nActualRows - 1; aRowHeaderArea.Bottom() = m_nColHeaderHeightPixel + m_nRowHeightPixel * nActualRows - 1;
pRenderer->PaintHeaderArea( *m_pDataWindow, aRowHeaderArea, false, true, rStyle ); pRenderer->PaintHeaderArea(rRenderContext, aRowHeaderArea, false, true, rStyle);
// Note that strictly, aRowHeaderArea also contains the intersection between column // Note that strictly, aRowHeaderArea also contains the intersection between column
// and row header area. However, below we go to paint this intersection, again, // and row header area. However, below we go to paint this intersection, again,
// so this hopefully doesn't hurt if we already paint it here. // so this hopefully doesn't hurt if we already paint it here.
if ( m_pModel->hasColumnHeaders() ) if (m_pModel->hasColumnHeaders())
{ {
TableCellGeometry const aIntersection( *this, Rectangle( Point( 0, 0 ), TableCellGeometry const aIntersection(*this, Rectangle(Point(0, 0), aAllCellsWithHeaders.BottomRight()),
aAllCellsWithHeaders.BottomRight() ), COL_ROW_HEADERS, ROW_COL_HEADERS ); COL_ROW_HEADERS, ROW_COL_HEADERS);
Rectangle const aInters( aIntersection.getRect() ); Rectangle const aInters(aIntersection.getRect());
pRenderer->PaintHeaderArea( pRenderer->PaintHeaderArea(rRenderContext, aInters, true, true, rStyle);
*m_pDataWindow, aInters, true, true, rStyle
);
} }
} }
// draw the table content row by row // draw the table content row by row
TableSize colCount = getModel()->getColumnCount(); TableSize colCount = getModel()->getColumnCount();
// paint all rows // paint all rows
Rectangle const aAllDataCellsArea( impl_getAllVisibleDataCellArea() ); Rectangle const aAllDataCellsArea(impl_getAllVisibleDataCellArea());
for ( TableRowGeometry aRowIterator( *this, aAllCellsWithHeaders, getTopRow() ); for (TableRowGeometry aRowIterator(*this, aAllCellsWithHeaders, getTopRow()); aRowIterator.isValid(); aRowIterator.moveDown())
aRowIterator.isValid();
aRowIterator.moveDown() )
{ {
if ( _rUpdateRect.GetIntersection( aRowIterator.getRect() ).IsEmpty() ) if (_rUpdateRect.GetIntersection(aRowIterator.getRect() ).IsEmpty())
continue; continue;
bool const isControlFocused = m_rAntiImpl.HasControlFocus(); 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(), isControlFocused, isSelectedRow, rRenderContext, aRect, rStyle);
aRowIterator.getRow(), isControlFocused, isSelectedRow,
*m_pDataWindow, aRect, rStyle
);
// paint the row header // paint the row header
if ( m_pModel->hasRowHeaders() ) if (m_pModel->hasRowHeaders())
{ {
const Rectangle aCurrentRowHeader( aRowHeaderArea.GetIntersection( aRowIterator.getRect() ) ); const Rectangle aCurrentRowHeader(aRowHeaderArea.GetIntersection(aRowIterator.getRect()));
pRenderer->PaintRowHeader( isControlFocused, isSelectedRow, *m_pDataWindow, aCurrentRowHeader, pRenderer->PaintRowHeader(isControlFocused, isSelectedRow, rRenderContext, aCurrentRowHeader, rStyle);
rStyle );
} }
if ( !colCount ) if (!colCount)
continue; continue;
// paint all cells in this row // paint all cells in this row
for ( TableCellGeometry aCell( aRowIterator, m_nLeftColumn ); for (TableCellGeometry aCell(aRowIterator, m_nLeftColumn); aCell.isValid(); aCell.moveRight())
aCell.isValid();
aCell.moveRight()
)
{ {
bool isSelectedColumn = false; bool isSelectedColumn = false;
pRenderer->PaintCell( aCell.getColumn(), isSelectedRow || isSelectedColumn, isControlFocused, pRenderer->PaintCell(aCell.getColumn(), isSelectedRow || isSelectedColumn, isControlFocused,
*m_pDataWindow, aCell.getRect(), rStyle ); rRenderContext, aCell.getRect(), rStyle);
} }
} }
} }
......
...@@ -34,11 +34,8 @@ ...@@ -34,11 +34,8 @@
class ScrollBar; class ScrollBar;
class ScrollBarBox; class ScrollBarBox;
namespace svt { namespace table namespace svt { namespace table
{ {
struct MutableColumnMetrics : protected ColumnMetrics struct MutableColumnMetrics : protected ColumnMetrics
{ {
MutableColumnMetrics() MutableColumnMetrics()
...@@ -170,7 +167,7 @@ namespace svt { namespace table ...@@ -170,7 +167,7 @@ namespace svt { namespace table
/** paints the table control content which intersects with the given rectangle /** paints the table control content which intersects with the given rectangle
*/ */
void doPaintContent( const Rectangle& _rUpdateRect ); void doPaintContent(vcl::RenderContext& rRenderContext, const Rectangle& _rUpdateRect);
/** moves the cursor to the cell with the given coordinates /** moves the cursor to the cell with the given coordinates
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#include "table/tablecontrol.hxx" #include "table/tablecontrol.hxx"
#include "tabledatawindow.hxx" #include "tabledatawindow.hxx"
...@@ -27,16 +26,9 @@ ...@@ -27,16 +26,9 @@
#include <vcl/help.hxx> #include <vcl/help.hxx>
#include <vcl/settings.hxx> #include <vcl/settings.hxx>
namespace svt { namespace table namespace svt { namespace table
{ {
using css::uno::Any;
using ::com::sun::star::uno::Any;
//= TableDataWindow
TableDataWindow::TableDataWindow( TableControl_Impl& _rTableControl ) TableDataWindow::TableDataWindow( TableControl_Impl& _rTableControl )
:Window( &_rTableControl.getAntiImpl() ) :Window( &_rTableControl.getAntiImpl() )
...@@ -60,9 +52,9 @@ namespace svt { namespace table ...@@ -60,9 +52,9 @@ namespace svt { namespace table
Window::dispose(); Window::dispose();
} }
void TableDataWindow::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& rUpdateRect ) void TableDataWindow::Paint( vcl::RenderContext& rRenderContext, const Rectangle& rUpdateRect )
{ {
m_rTableControl.doPaintContent( rUpdateRect ); m_rTableControl.doPaintContent(rRenderContext, rUpdateRect);
} }
void TableDataWindow::SetBackground( const Wallpaper& rColor ) void TableDataWindow::SetBackground( const Wallpaper& rColor )
...@@ -221,7 +213,7 @@ namespace svt { namespace table ...@@ -221,7 +213,7 @@ namespace svt { namespace table
return nDone || Window::Notify( rNEvt ); return nDone || Window::Notify( rNEvt );
} }
} } // namespace svt::table }} // namespace svt::table
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -26,15 +26,9 @@ ...@@ -26,15 +26,9 @@
namespace svt { namespace table namespace svt { namespace table
{ {
class TableControl_Impl; class TableControl_Impl;
class TableFunctionSet; class TableFunctionSet;
//= TableDataWindow
/** the window containing the content area (including headers) of /** the window containing the content area (including headers) of
a table control a table control
*/ */
...@@ -51,11 +45,17 @@ namespace svt { namespace table ...@@ -51,11 +45,17 @@ namespace svt { namespace table
virtual ~TableDataWindow(); virtual ~TableDataWindow();
virtual void dispose() SAL_OVERRIDE; virtual void dispose() SAL_OVERRIDE;
inline void SetSelectHdl( const Link<>& rLink ) { m_aSelectHdl = rLink; } inline void SetSelectHdl(const Link<>& rLink)
inline const Link<>& GetSelectHdl() const { return m_aSelectHdl; } {
m_aSelectHdl = rLink;
}
inline const Link<>& GetSelectHdl() const
{
return m_aSelectHdl;
}
// Window overridables // Window overridables
virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE; virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) SAL_OVERRIDE;
virtual void MouseMove( const MouseEvent& rMEvt) SAL_OVERRIDE; virtual void MouseMove( const MouseEvent& rMEvt) SAL_OVERRIDE;
virtual void MouseButtonDown( const MouseEvent& rMEvt) SAL_OVERRIDE; virtual void MouseButtonDown( const MouseEvent& rMEvt) SAL_OVERRIDE;
virtual void MouseButtonUp( const MouseEvent& rMEvt) SAL_OVERRIDE; virtual void MouseButtonUp( const MouseEvent& rMEvt) SAL_OVERRIDE;
......
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