diff options
author | Frank Schoenheit [fs] <frank.schoenheit@oracle.com> | 2011-03-22 13:27:12 +0100 |
---|---|---|
committer | Frank Schoenheit [fs] <frank.schoenheit@oracle.com> | 2011-03-22 13:27:12 +0100 |
commit | e2de537d59150b7fc13618d5f3821fe2213f974e (patch) | |
tree | c48aafedeabc9af08abf3845305bf1612299232a /svtools/source/table | |
parent | d004c1413059aee774dbf0ee9cbab606feb8ef42 (diff) |
gridfixes: #i117398# allow to specify selection-related colors in table/grid control models (VCL/UNO)
Diffstat (limited to 'svtools/source/table')
-rw-r--r-- | svtools/source/table/gridtablerenderer.cxx | 27 | ||||
-rwxr-xr-x | svtools/source/table/tablecontrol_impl.cxx | 16 |
2 files changed, 36 insertions, 7 deletions
diff --git a/svtools/source/table/gridtablerenderer.cxx b/svtools/source/table/gridtablerenderer.cxx index 92cf6232e7a3..247da41e9b6a 100644 --- a/svtools/source/table/gridtablerenderer.cxx +++ b/svtools/source/table/gridtablerenderer.cxx @@ -338,13 +338,17 @@ namespace svt { namespace table ::Color backgroundColor = _rStyle.GetFieldColor(); - ::boost::optional< ::Color > aLineColor( m_pImpl->rModel.getLineColor() ); + ::boost::optional< ::Color > const aLineColor( m_pImpl->rModel.getLineColor() ); ::Color lineColor = !aLineColor ? _rStyle.GetSeparatorColor() : *aLineColor; + ::Color const activeSelectionBackColor = + lcl_getEffectiveColor( m_pImpl->rModel.getActiveSelectionBackColor(), _rStyle, &StyleSettings::GetHighlightColor ); if ( _bSelected ) { // selected rows use the background color from the style - backgroundColor = i_hasControlFocus ? _rStyle.GetHighlightColor() : _rStyle.GetDeactiveColor(); + backgroundColor = i_hasControlFocus + ? activeSelectionBackColor + : lcl_getEffectiveColor( m_pImpl->rModel.getInactiveSelectionBackColor(), _rStyle, &StyleSettings::GetDeactiveColor ); if ( !aLineColor ) lineColor = backgroundColor; } @@ -361,7 +365,7 @@ namespace svt { namespace table } else { - Color hilightColor = _rStyle.GetHighlightColor(); + Color hilightColor = activeSelectionBackColor; hilightColor.SetRed( 9 * ( fieldColor.GetRed() - hilightColor.GetRed() ) / 10 + hilightColor.GetRed() ); hilightColor.SetGreen( 9 * ( fieldColor.GetGreen() - hilightColor.GetGreen() ) / 10 + hilightColor.GetGreen() ); hilightColor.SetBlue( 9 * ( fieldColor.GetBlue() - hilightColor.GetBlue() ) / 10 + hilightColor.GetBlue() ); @@ -427,14 +431,16 @@ namespace svt { namespace table StyleSettings const & rStyle; ColPos const nColumn; bool const bSelected; + bool const bHasControlFocus; CellRenderContext( OutputDevice& i_device, Rectangle const & i_contentArea, - StyleSettings const & i_style, ColPos const i_column, bool const i_selected ) + StyleSettings const & i_style, ColPos const i_column, bool const i_selected, bool const i_hasControlFocus ) :rDevice( i_device ) ,aContentArea( i_contentArea ) ,rStyle( i_style ) ,nColumn( i_column ) ,bSelected( i_selected ) + ,bHasControlFocus( i_hasControlFocus ) { } }; @@ -446,7 +452,7 @@ namespace svt { namespace table _rDevice.Push( PUSH_LINECOLOR | PUSH_FILLCOLOR ); Rectangle const aContentArea( lcl_getContentArea( *m_pImpl, _rArea ) ); - CellRenderContext const aRenderContext( _rDevice, aContentArea, _rStyle, i_column, _bSelected ); + CellRenderContext const aRenderContext( _rDevice, aContentArea, _rStyle, i_column, _bSelected, i_hasControlFocus ); impl_paintCellContent( aRenderContext ); if ( m_pImpl->bUseGridLines ) @@ -457,7 +463,9 @@ namespace svt { namespace table if ( _bSelected && !aLineColor ) { // if no line color is specified by the model, use the usual selection color for lines in selected cells - lineColor = i_hasControlFocus ? _rStyle.GetHighlightColor() : _rStyle.GetDeactiveColor(); + lineColor = i_hasControlFocus + ? lcl_getEffectiveColor( m_pImpl->rModel.getActiveSelectionBackColor(), _rStyle, &StyleSettings::GetHighlightColor ) + : lcl_getEffectiveColor( m_pImpl->rModel.getInactiveSelectionBackColor(), _rStyle, &StyleSettings::GetDeactiveColor ); } _rDevice.SetLineColor( lineColor ); @@ -542,7 +550,12 @@ namespace svt { namespace table void GridTableRenderer::impl_paintCellText( CellRenderContext const & i_context, ::rtl::OUString const & i_text ) { if ( i_context.bSelected ) - i_context.rDevice.SetTextColor( i_context.rStyle.GetHighlightTextColor() ); + { + ::Color const textColor = i_context.bHasControlFocus + ? lcl_getEffectiveColor( m_pImpl->rModel.getActiveSelectionTextColor(), i_context.rStyle, &StyleSettings::GetHighlightTextColor ) + : lcl_getEffectiveColor( m_pImpl->rModel.getInactiveSelectionTextColor(), i_context.rStyle, &StyleSettings::GetDeactiveTextColor ); + i_context.rDevice.SetTextColor( textColor ); + } else { ::Color const textColor = lcl_getEffectiveColor( m_pImpl->rModel.getTextColor(), i_context.rStyle, &StyleSettings::GetFieldTextColor ); diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index 2c23a9c93fe3..bb7be1c4ccfe 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -185,6 +185,22 @@ namespace svt { namespace table { return ::boost::optional< ::Color >(); } + virtual ::boost::optional< ::Color > getActiveSelectionBackColor() const + { + return ::boost::optional< ::Color >(); + } + virtual ::boost::optional< ::Color > getInactiveSelectionBackColor() const + { + return ::boost::optional< ::Color >(); + } + virtual ::boost::optional< ::Color > getActiveSelectionTextColor() const + { + return ::boost::optional< ::Color >(); + } + virtual ::boost::optional< ::Color > getInactiveSelectionTextColor() const + { + return ::boost::optional< ::Color >(); + } virtual ::boost::optional< ::Color > getTextColor() const { return ::boost::optional< ::Color >(); |