LibreOffice Module toolkit (master) 1
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
svt::table::GridTableRenderer Class Referencefinal

a default implementation for the ->ITableRenderer interface More...

#include <gridtablerenderer.hxx>

Inheritance diagram for svt::table::GridTableRenderer:
[legend]
Collaboration diagram for svt::table::GridTableRenderer:
[legend]

Classes

struct  CellRenderContext
 

Public Member Functions

 GridTableRenderer (ITableModel &_rModel)
 creates a table renderer associated with the given model More...
 
virtual ~GridTableRenderer () override
 
bool useGridLines () const
 determines whether or not to paint grid lines More...
 
void useGridLines (bool const i_use)
 controls whether or not to paint grid lines More...
 
virtual void PaintHeaderArea (vcl::RenderContext &_rDevice, const tools::Rectangle &_rArea, bool _bIsColHeaderArea, bool _bIsRowHeaderArea, const StyleSettings &_rStyle) override
 paints a (part of) header area More...
 
virtual void PaintColumnHeader (ColPos _nCol, vcl::RenderContext &_rDevice, const tools::Rectangle &_rArea, const StyleSettings &_rStyle) override
 paints the header for a given column More...
 
virtual void PrepareRow (RowPos _nRow, bool i_hasControlFocus, bool _bSelected, vcl::RenderContext &_rDevice, const tools::Rectangle &_rRowArea, const StyleSettings &_rStyle) override
 prepares a row for painting More...
 
virtual void PaintRowHeader (vcl::RenderContext &_rDevice, const tools::Rectangle &_rArea, const StyleSettings &_rStyle) override
 paints the header of a row More...
 
virtual void PaintCell (ColPos const i_col, bool i_hasControlFocus, bool _bSelected, vcl::RenderContext &_rDevice, const tools::Rectangle &_rArea, const StyleSettings &_rStyle) override
 paints a certain cell More...
 
virtual void ShowCellCursor (vcl::Window &_rView, const tools::Rectangle &_rCursorRect) override
 draws a cell cursor in the given rectangle More...
 
virtual void HideCellCursor (vcl::Window &_rView) override
 hides the cell cursor previously drawn into the given rectangle More...
 
virtual bool FitsIntoCell (css::uno::Any const &i_cellContent, OutputDevice &i_targetDevice, tools::Rectangle const &i_targetArea) const override
 checks whether a given cell content fits into a given target area on a given device. More...
 
virtual bool GetFormattedCellString (css::uno::Any const &i_cellValue, OUString &o_cellString) const override
 attempts to format the content of the given cell as string More...
 
- Public Member Functions inherited from svt::table::ITableRenderer
virtual void PaintHeaderArea (vcl::RenderContext &_rDevice, const tools::Rectangle &_rArea, bool _bIsColHeaderArea, bool _bIsRowHeaderArea, const StyleSettings &_rStyle)=0
 paints a (part of) header area More...
 
virtual void PaintColumnHeader (ColPos _nCol, vcl::RenderContext &_rDevice, const tools::Rectangle &_rArea, const StyleSettings &_rStyle)=0
 paints the header for a given column More...
 
virtual void PrepareRow (RowPos _nRow, bool i_hasControlFocus, bool _bSelected, vcl::RenderContext &_rDevice, const tools::Rectangle &_rRowArea, const StyleSettings &_rStyle)=0
 prepares a row for painting More...
 
virtual void PaintRowHeader (vcl::RenderContext &_rDevice, tools::Rectangle const &_rArea, StyleSettings const &_rStyle)=0
 paints the header of a row More...
 
virtual void PaintCell (ColPos const i_col, bool i_hasControlFocus, bool _bSelected, vcl::RenderContext &_rDevice, const tools::Rectangle &_rArea, const StyleSettings &_rStyle)=0
 paints a certain cell More...
 
virtual void ShowCellCursor (vcl::Window &_rView, const tools::Rectangle &_rCursorRect)=0
 draws a cell cursor in the given rectangle More...
 
virtual void HideCellCursor (vcl::Window &_rView)=0
 hides the cell cursor previously drawn into the given rectangle More...
 
virtual bool FitsIntoCell (css::uno::Any const &i_cellContent, OutputDevice &i_targetDevice, tools::Rectangle const &i_targetArea) const =0
 checks whether a given cell content fits into a given target area on a given device. More...
 
virtual bool GetFormattedCellString (css::uno::Any const &i_cellValue, OUString &o_cellString) const =0
 attempts to format the content of the given cell as string More...
 
virtual ~ITableRenderer ()
 deletes the renderer instance More...
 

Private Member Functions

void impl_paintCellContent (CellRenderContext const &i_context)
 
void impl_paintCellImage (CellRenderContext const &i_context, Image const &i_image)
 
void impl_paintCellText (CellRenderContext const &i_context, OUString const &i_text)
 

Private Attributes

::std::unique_ptr< GridTableRenderer_Implm_pImpl
 

Detailed Description

a default implementation for the ->ITableRenderer interface

This class is able to paint a table grid, table headers, and cell backgrounds according to the selected/active state of cells.

Definition at line 42 of file gridtablerenderer.hxx.

Constructor & Destructor Documentation

◆ GridTableRenderer()

svt::table::GridTableRenderer::GridTableRenderer ( ITableModel _rModel)

creates a table renderer associated with the given model

Parameters
_rModelthe model which should be rendered. The caller is responsible for lifetime control, that is, the model instance must live at least as long as the renderer instance lives

Definition at line 180 of file gridtablerenderer.cxx.

References m_pImpl.

◆ ~GridTableRenderer()

svt::table::GridTableRenderer::~GridTableRenderer ( )
overridevirtual

Definition at line 186 of file gridtablerenderer.cxx.

Member Function Documentation

◆ FitsIntoCell()

bool svt::table::GridTableRenderer::FitsIntoCell ( css::uno::Any const &  i_cellContent,
OutputDevice i_targetDevice,
tools::Rectangle const &  i_targetArea 
) const
overridevirtual

checks whether a given cell content fits into a given target area on a given device.

Parameters
i_targetDevicedenotes the target device for the assumed rendering operation
i_targetAreadenotes the area within the target device for the assumed rendering operation.
Returns
<TRUE> if and only if the given cell content could be rendered into the given device and the given area.

Implements svt::table::ITableRenderer.

Definition at line 550 of file gridtablerenderer.cxx.

References tools::Rectangle::GetHeight(), OutputDevice::GetTextHeight(), OutputDevice::GetTextWidth(), tools::Rectangle::GetWidth(), and m_pImpl.

◆ GetFormattedCellString()

bool svt::table::GridTableRenderer::GetFormattedCellString ( css::uno::Any const &  i_cellValue,
OUString &  o_cellString 
) const
overridevirtual

attempts to format the content of the given cell as string

Parameters
i_cellValuethe value for which an attempt for a string conversion should be made
o_cellStringthe cell content, formatted as string
Returns
<TRUE> if and only if the content could be formatted as string

Implements svt::table::ITableRenderer.

Definition at line 586 of file gridtablerenderer.cxx.

References m_pImpl.

◆ HideCellCursor()

void svt::table::GridTableRenderer::HideCellCursor ( vcl::Window _rView)
overridevirtual

hides the cell cursor previously drawn into the given rectangle

The cell cursor is used to indicate the active/current cell of a table control.

Implements svt::table::ITableRenderer.

Definition at line 544 of file gridtablerenderer.cxx.

References vcl::Window::HideFocus().

◆ impl_paintCellContent()

void svt::table::GridTableRenderer::impl_paintCellContent ( CellRenderContext const &  i_context)
private

◆ impl_paintCellImage()

void svt::table::GridTableRenderer::impl_paintCellImage ( CellRenderContext const &  i_context,
Image const &  i_image 
)
private

◆ impl_paintCellText()

void svt::table::GridTableRenderer::impl_paintCellText ( CellRenderContext const &  i_context,
OUString const &  i_text 
)
private

◆ PaintCell()

void svt::table::GridTableRenderer::PaintCell ( ColPos const  i_col,
bool  i_hasControlFocus,
bool  _bSelected,
vcl::RenderContext _rDevice,
const tools::Rectangle _rArea,
const StyleSettings _rStyle 
)
overridevirtual

paints a certain cell

The row to be painted is denoted by the most recent call to ->PrepareRow.

Parameters
_bSelected<TRUE> if and only if the cell to be painted is selected currently. This is the case if either the row or the column of the cell is currently selected.
Note that this flag is equal to the respective flag in the previous ->PrepareRow call, it's passed here for convenience only.
i_hasControlFocus<TRUE> if and only if the table control currently has the focus
Note that this flag is equal to the respective flag in the previous ->PrepareRow call, it's passed here for convenience only.
_rDevicedenotes the device to paint onto
_rAreathe are into which the cell should be painted
_rStylethe style to be used for drawing

Implements svt::table::ITableRenderer.

Definition at line 414 of file gridtablerenderer.cxx.

References tools::Rectangle::BottomLeft(), tools::Rectangle::BottomRight(), OutputDevice::DrawLine(), vcl::FILLCOLOR, StyleSettings::GetDeactiveColor(), StyleSettings::GetHighlightColor(), StyleSettings::GetSeparatorColor(), impl_paintCellContent(), vcl::LINECOLOR, m_pImpl, OutputDevice::Pop(), OutputDevice::Push(), OutputDevice::SetLineColor(), and tools::Rectangle::TopRight().

◆ PaintColumnHeader()

void svt::table::GridTableRenderer::PaintColumnHeader ( ColPos  _nCol,
vcl::RenderContext _rDevice,
const tools::Rectangle _rArea,
const StyleSettings _rStyle 
)
overridevirtual

◆ PaintHeaderArea()

void svt::table::GridTableRenderer::PaintHeaderArea ( vcl::RenderContext _rDevice,
const tools::Rectangle _rArea,
bool  _bIsColHeaderArea,
bool  _bIsRowHeaderArea,
const StyleSettings _rStyle 
)
overridevirtual

paints a (part of) header area

There are two header areas in a table control:

  • The row containing all column headers, i.e. above all rows containing the data
  • The column containing all row headers. i.e. left of all columns containing the data

A header area is more than the union of the single column/row headers.

First, there might be less columns than fit into the view - in this case, right beside the right-most column, there's still room which belongs to the column header area, but is not occupied by any particular column header.
An equivalent statement holds for the row header area, if there are fewer rows than fit into the view.

Second, if the table control has both a row header and a column header, the intersection between those both belongs to both the column header area and the row header area, but not to any particular column or row header.

There are two flags specifying whether the to-be-painted area is part of the column and/or row header area.

  • If both are <TRUE>, the intersection of both areas is to be painted.
  • If ->_bIsColHeaderArea is <TRUE> and ->_bIsRowHeaderArea is <FALSE>, then ->_rArea denotes the column header area excluding the intersection between row and column header area.
  • Equivalently for ->_bIsColHeaderArea being <FALSE> and ->_bIsRowHeaderArea being <TRUE>

Note that it's not possible for both ->_bIsColHeaderArea and ->_bIsRowHeaderArea to be <FALSE> at the same time.

Parameters
_rDevicethe device to paint onto
_rAreathe area to paint into
_bIsColHeaderArea<TRUE> if and only if ->_rArea is part of the column header area.
_bIsRowHeaderArea<TRUE> if and only if ->_rArea is part of the row header area.
_rStylethe style to be used for drawing

Implements svt::table::ITableRenderer.

Definition at line 216 of file gridtablerenderer.cxx.

References tools::Rectangle::BottomLeft(), tools::Rectangle::BottomRight(), OutputDevice::DrawLine(), OutputDevice::DrawRect(), vcl::FILLCOLOR, StyleSettings::GetDialogColor(), StyleSettings::GetSeparatorColor(), vcl::LINECOLOR, m_pImpl, OutputDevice::Pop(), OutputDevice::Push(), OutputDevice::SetFillColor(), OutputDevice::SetLineColor(), and tools::Rectangle::TopRight().

◆ PaintRowHeader()

void svt::table::GridTableRenderer::PaintRowHeader ( vcl::RenderContext _rDevice,
const tools::Rectangle _rArea,
const StyleSettings _rStyle 
)
overridevirtual

paints the header of a row

The row to be painted is denoted by the most recent call to ->PrepareRow.

Parameters
_rDevicedenotes the device to paint onto
_rAreathe are into which the row header should be painted
_rStylethe style to be used for drawing

Implements svt::table::ITableRenderer.

Definition at line 362 of file gridtablerenderer.cxx.

References Any, tools::Rectangle::BottomLeft(), tools::Rectangle::BottomRight(), OutputDevice::DrawLine(), OutputDevice::DrawText(), StyleSettings::GetFieldTextColor(), StyleSettings::GetSeparatorColor(), vcl::LINECOLOR, m_pImpl, OutputDevice::Pop(), OutputDevice::Push(), OutputDevice::SetLineColor(), OutputDevice::SetTextColor(), and vcl::TEXTCOLOR.

◆ PrepareRow()

void svt::table::GridTableRenderer::PrepareRow ( RowPos  _nRow,
bool  i_hasControlFocus,
bool  _bSelected,
vcl::RenderContext _rDevice,
const tools::Rectangle _rRowArea,
const StyleSettings _rStyle 
)
overridevirtual

prepares a row for painting

Painting a table means painting rows as necessary, in an increasing order. The assumption is that retrieving data for two different rows is (potentially) more expensive than retrieving data for two different columns. Thus, the renderer will get the chance to "seek" to a certain row, and then has to render all cells in this row, before another row is going to be painted.

Parameters
_nRowthe row which is going to be painted. The renderer should at least remember this row, since subsequent calls to ->PaintRowHeader(), ->PaintCell(), and ->FinishRow() will not pass this parameter again.

However, the renderer is also allowed to render any cell-independent content of this row.

Parameters
i_hasControlFocus<TRUE> if and only if the table control currently has the focus
_bSelected<TRUE> if and only if the row to be prepared is selected currently.
_rDevicedenotes the device to paint onto
_rRowAreathe are into which the row should be painted. This excludes the row header area, if applicable.
_rStylethe style to be used for drawing

Implements svt::table::ITableRenderer.

Definition at line 301 of file gridtablerenderer.cxx.

References OutputDevice::DrawRect(), vcl::FILLCOLOR, Color::GetBlue(), StyleSettings::GetDeactiveColor(), StyleSettings::GetFieldColor(), Color::GetGreen(), StyleSettings::GetHighContrastMode(), StyleSettings::GetHighlightColor(), Color::GetRed(), vcl::LINECOLOR, m_pImpl, OutputDevice::Pop(), OutputDevice::Push(), Color::SetBlue(), OutputDevice::SetFillColor(), Color::SetGreen(), OutputDevice::SetLineColor(), and Color::SetRed().

◆ ShowCellCursor()

void svt::table::GridTableRenderer::ShowCellCursor ( vcl::Window _rView,
const tools::Rectangle _rCursorRect 
)
overridevirtual

draws a cell cursor in the given rectangle

The cell cursor is used to indicate the active/current cell of a table control.

Implements svt::table::ITableRenderer.

Definition at line 538 of file gridtablerenderer.cxx.

References vcl::Window::ShowFocus().

◆ useGridLines() [1/2]

bool svt::table::GridTableRenderer::useGridLines ( ) const

determines whether or not to paint grid lines

Definition at line 191 of file gridtablerenderer.cxx.

References m_pImpl.

◆ useGridLines() [2/2]

void svt::table::GridTableRenderer::useGridLines ( bool const  i_use)

controls whether or not to paint grid lines

Definition at line 197 of file gridtablerenderer.cxx.

References m_pImpl.

Member Data Documentation

◆ m_pImpl

::std::unique_ptr< GridTableRenderer_Impl > svt::table::GridTableRenderer::m_pImpl
private

The documentation for this class was generated from the following files: