summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorNorbert Thiebaud <nthiebaud@gmail.com>2012-09-03 12:20:27 -0500
committerMiklos Vajna <vmiklos@suse.cz>2012-09-14 09:38:47 +0200
commitfe08068cf9ba35105955244b8d9cd9e64e3ebb88 (patch)
treee32e2bd869f03df3421fd4190d6ef76d24533bda /svtools
parent5200140683c461e7439d8f2b5a625391350a2cef (diff)
gridfixes: #i117398# allow to specify selection colors in table/grid
Conflicts: toolkit/inc/toolkit/helper/property.hxx toolkit/source/controls/grid/defaultgriddatamodel.cxx Change-Id: Ie863aa7cecb4c7bda230ab829e6090689518dab8
Diffstat (limited to 'svtools')
-rw-r--r--svtools/inc/svtools/table/tablemodel.hxx24
-rw-r--r--svtools/source/table/gridtablerenderer.cxx27
-rw-r--r--svtools/source/table/tablecontrol_impl.cxx16
-rw-r--r--svtools/source/uno/svtxgridcontrol.cxx39
-rw-r--r--svtools/source/uno/unocontroltablemodel.cxx98
-rw-r--r--svtools/source/uno/unocontroltablemodel.hxx8
6 files changed, 187 insertions, 25 deletions
diff --git a/svtools/inc/svtools/table/tablemodel.hxx b/svtools/inc/svtools/table/tablemodel.hxx
index 6e962befefc8..9093a234f2a0 100644
--- a/svtools/inc/svtools/table/tablemodel.hxx
+++ b/svtools/inc/svtools/table/tablemodel.hxx
@@ -473,6 +473,30 @@ namespace svt { namespace table
*/
virtual ::boost::optional< ::Color > getHeaderTextColor() const = 0;
+ /** returns the color to be used for the background of selected cells, when the control has the focus
+
+ If this value is not set, a default color from the style settings will be used.
+ */
+ virtual ::boost::optional< ::Color > getActiveSelectionBackColor() const = 0;
+
+ /** returns the color to be used for the background of selected cells, when the control does not have the focus
+
+ If this value is not set, a default color from the style settings will be used.
+ */
+ virtual ::boost::optional< ::Color > getInactiveSelectionBackColor() const = 0;
+
+ /** returns the color to be used for the text of selected cells, when the control has the focus
+
+ If this value is not set, a default color from the style settings will be used.
+ */
+ virtual ::boost::optional< ::Color > getActiveSelectionTextColor() const = 0;
+
+ /** returns the color to be used for the text of selected cells, when the control does not have the focus
+
+ If this value is not set, a default color from the style settings will be used.
+ */
+ virtual ::boost::optional< ::Color > getInactiveSelectionTextColor() const = 0;
+
/** returns the color to be used for rendering cell texts.
If this value is not set, a default color from the style settings will be used.
diff --git a/svtools/source/table/gridtablerenderer.cxx b/svtools/source/table/gridtablerenderer.cxx
index 67ddb52aabaa..8e227b6ab9b6 100644
--- a/svtools/source/table/gridtablerenderer.cxx
+++ b/svtools/source/table/gridtablerenderer.cxx
@@ -330,13 +330,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;
}
@@ -353,7 +357,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() );
@@ -419,14 +423,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 )
{
}
};
@@ -438,7 +444,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 )
@@ -449,7 +455,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 );
@@ -534,7 +542,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 a9539cbd7aca..521bb2d79e9f 100644
--- a/svtools/source/table/tablecontrol_impl.cxx
+++ b/svtools/source/table/tablecontrol_impl.cxx
@@ -182,6 +182,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 >();
diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx
index fa3246659dbc..df19233354d8 100644
--- a/svtools/source/uno/svtxgridcontrol.cxx
+++ b/svtools/source/uno/svtxgridcontrol.cxx
@@ -332,6 +332,27 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An
pTable->Invalidate();
break;
+ case BASEPROPERTY_ACTIVE_SEL_BACKGROUND_COLOR:
+ m_pTableModel->setActiveSelectionBackColor( aValue );
+ pTable->Invalidate();
+ break;
+
+ case BASEPROPERTY_INACTIVE_SEL_BACKGROUND_COLOR:
+ m_pTableModel->setInactiveSelectionBackColor( aValue );
+ pTable->Invalidate();
+ break;
+
+ case BASEPROPERTY_ACTIVE_SEL_TEXT_COLOR:
+ m_pTableModel->setActiveSelectionTextColor( aValue );
+ pTable->Invalidate();
+ break;
+
+ case BASEPROPERTY_INACTIVE_SEL_TEXT_COLOR:
+ m_pTableModel->setInactiveSelectionTextColor( aValue );
+ pTable->Invalidate();
+ break;
+
+
case BASEPROPERTY_TEXTCOLOR:
m_pTableModel->setTextColor( aValue );
pTable->Invalidate();
@@ -530,6 +551,22 @@ Any SVTXGridControl::getProperty( const ::rtl::OUString& PropertyName ) throw(Ru
lcl_convertColor( m_pTableModel->getHeaderTextColor(), aPropertyValue );
break;
+ case BASEPROPERTY_ACTIVE_SEL_BACKGROUND_COLOR:
+ lcl_convertColor( m_pTableModel->getActiveSelectionBackColor(), aPropertyValue );
+ break;
+
+ case BASEPROPERTY_INACTIVE_SEL_BACKGROUND_COLOR:
+ lcl_convertColor( m_pTableModel->getInactiveSelectionBackColor(), aPropertyValue );
+ break;
+
+ case BASEPROPERTY_ACTIVE_SEL_TEXT_COLOR:
+ lcl_convertColor( m_pTableModel->getActiveSelectionTextColor(), aPropertyValue );
+ break;
+
+ case BASEPROPERTY_INACTIVE_SEL_TEXT_COLOR:
+ lcl_convertColor( m_pTableModel->getInactiveSelectionTextColor(), aPropertyValue );
+ break;
+
case BASEPROPERTY_TEXTCOLOR:
lcl_convertColor( m_pTableModel->getTextColor(), aPropertyValue );
break;
@@ -849,4 +886,4 @@ void SVTXGridControl::impl_updateColumnsFromModel_nothrow()
}
}
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx
index f363d4a950b8..9c8a0b0fb627 100644
--- a/svtools/source/uno/unocontroltablemodel.cxx
+++ b/svtools/source/uno/unocontroltablemodel.cxx
@@ -95,6 +95,10 @@ namespace svt { namespace table
::boost::optional< ::Color > m_aGridLineColor;
::boost::optional< ::Color > m_aHeaderBackgroundColor;
::boost::optional< ::Color > m_aHeaderTextColor;
+ ::boost::optional< ::Color > m_aActiveSelectionBackColor;
+ ::boost::optional< ::Color > m_aInactiveSelectionBackColor;
+ ::boost::optional< ::Color > m_aActiveSelectionTextColor;
+ ::boost::optional< ::Color > m_aInactiveSelectionTextColor;
::boost::optional< ::Color > m_aTextColor;
::boost::optional< ::Color > m_aTextLineColor;
::boost::optional< ::std::vector< ::Color > > m_aRowColors;
@@ -104,23 +108,27 @@ namespace svt { namespace table
WeakReference< XGridColumnModel > m_aColumnModel;
UnoControlTableModel_Impl()
- :aColumns ( )
- ,bHasColumnHeaders ( true )
- ,bHasRowHeaders ( false )
- ,eVScrollMode ( ScrollbarShowNever )
- ,eHScrollMode ( ScrollbarShowNever )
- ,pRenderer ( )
- ,pInputHandler ( )
- ,nRowHeight ( 10 )
- ,nColumnHeaderHeight ( 10 )
- ,nRowHeaderWidth ( 10 )
- ,m_aGridLineColor ( )
- ,m_aHeaderBackgroundColor ( )
- ,m_aHeaderTextColor ( )
- ,m_aTextColor ( )
- ,m_aTextLineColor ( )
- ,m_aRowColors ( )
- ,m_eVerticalAlign ( VerticalAlignment_TOP )
+ :aColumns ( )
+ ,bHasColumnHeaders ( true )
+ ,bHasRowHeaders ( false )
+ ,eVScrollMode ( ScrollbarShowNever )
+ ,eHScrollMode ( ScrollbarShowNever )
+ ,pRenderer ( )
+ ,pInputHandler ( )
+ ,nRowHeight ( 10 )
+ ,nColumnHeaderHeight ( 10 )
+ ,nRowHeaderWidth ( 10 )
+ ,m_aGridLineColor ( )
+ ,m_aHeaderBackgroundColor ( )
+ ,m_aHeaderTextColor ( )
+ ,m_aActiveSelectionBackColor ( )
+ ,m_aInactiveSelectionBackColor ( )
+ ,m_aActiveSelectionTextColor ( )
+ ,m_aInactiveSelectionTextColor ( )
+ ,m_aTextColor ( )
+ ,m_aTextLineColor ( )
+ ,m_aRowColors ( )
+ ,m_eVerticalAlign ( VerticalAlignment_TOP )
{
}
};
@@ -656,6 +664,34 @@ namespace svt { namespace table
}
//------------------------------------------------------------------------------------------------------------------
+ ::boost::optional< ::Color > UnoControlTableModel::getActiveSelectionBackColor() const
+ {
+ DBG_CHECK_ME();
+ return m_pImpl->m_aActiveSelectionBackColor;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ::boost::optional< ::Color > UnoControlTableModel::getInactiveSelectionBackColor() const
+ {
+ DBG_CHECK_ME();
+ return m_pImpl->m_aInactiveSelectionBackColor;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ::boost::optional< ::Color > UnoControlTableModel::getActiveSelectionTextColor() const
+ {
+ DBG_CHECK_ME();
+ return m_pImpl->m_aActiveSelectionTextColor;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ::boost::optional< ::Color > UnoControlTableModel::getInactiveSelectionTextColor() const
+ {
+ DBG_CHECK_ME();
+ return m_pImpl->m_aInactiveSelectionTextColor;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
void UnoControlTableModel::setHeaderTextColor( Any const & i_color )
{
DBG_CHECK_ME();
@@ -663,6 +699,34 @@ namespace svt { namespace table
}
//------------------------------------------------------------------------------------------------------------------
+ void UnoControlTableModel::setActiveSelectionBackColor( Any const & i_color )
+ {
+ DBG_CHECK_ME();
+ lcl_setColor( i_color, m_pImpl->m_aActiveSelectionBackColor );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoControlTableModel::setInactiveSelectionBackColor( Any const & i_color )
+ {
+ DBG_CHECK_ME();
+ lcl_setColor( i_color, m_pImpl->m_aInactiveSelectionBackColor );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoControlTableModel::setActiveSelectionTextColor( Any const & i_color )
+ {
+ DBG_CHECK_ME();
+ lcl_setColor( i_color, m_pImpl->m_aActiveSelectionTextColor );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoControlTableModel::setInactiveSelectionTextColor( Any const & i_color )
+ {
+ DBG_CHECK_ME();
+ lcl_setColor( i_color, m_pImpl->m_aInactiveSelectionTextColor );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
::boost::optional< ::Color > UnoControlTableModel::getTextColor() const
{
DBG_CHECK_ME();
diff --git a/svtools/source/uno/unocontroltablemodel.hxx b/svtools/source/uno/unocontroltablemodel.hxx
index 15881dde71b2..43fbad3047b9 100644
--- a/svtools/source/uno/unocontroltablemodel.hxx
+++ b/svtools/source/uno/unocontroltablemodel.hxx
@@ -88,6 +88,10 @@ namespace svt { namespace table
virtual ::boost::optional< ::Color > getLineColor() const;
virtual ::boost::optional< ::Color > getHeaderBackgroundColor() const;
virtual ::boost::optional< ::Color > getHeaderTextColor() const;
+ virtual ::boost::optional< ::Color > getActiveSelectionBackColor() const;
+ virtual ::boost::optional< ::Color > getInactiveSelectionBackColor() const;
+ virtual ::boost::optional< ::Color > getActiveSelectionTextColor() const;
+ virtual ::boost::optional< ::Color > getInactiveSelectionTextColor() const;
virtual ::boost::optional< ::Color > getTextColor() const;
virtual ::boost::optional< ::Color > getTextLineColor() const;
virtual ::boost::optional< ::std::vector< ::Color > >
@@ -129,6 +133,10 @@ namespace svt { namespace table
void setLineColor( ::com::sun::star::uno::Any const & i_color );
void setHeaderBackgroundColor( ::com::sun::star::uno::Any const & i_color );
void setHeaderTextColor( ::com::sun::star::uno::Any const & i_color );
+ void setActiveSelectionBackColor( ::com::sun::star::uno::Any const & i_color );
+ void setInactiveSelectionBackColor( ::com::sun::star::uno::Any const & i_color );
+ void setActiveSelectionTextColor( ::com::sun::star::uno::Any const & i_color );
+ void setInactiveSelectionTextColor( ::com::sun::star::uno::Any const & i_color );
void setTextColor( ::com::sun::star::uno::Any const & i_color );
void setTextLineColor( ::com::sun::star::uno::Any const & i_color );
void setRowBackgroundColors( ::com::sun::star::uno::Any const & i_APIValue );