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() );
......
...@@ -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