1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SVTOOLS_TABLE_TABLERENDERER_HXX
21 #define INCLUDED_SVTOOLS_TABLE_TABLERENDERER_HXX
23 #include <svtools/table/tabletypes.hxx>
25 #include <vcl/outdev.hxx>
32 namespace svt
{ namespace table
39 /** interface to implement by components rendering a ->TableControl
41 class SAL_NO_VTABLE ITableRenderer
45 /** paints a (part of) header area
47 There are two header areas in a table control:
48 <ul><li>The row containing all column headers, i.e. <em>above</em> all rows containing the data</li>
49 <li>The column containing all row headers. i.e. <em>left of</em> all columns containing the data</li>
52 A header area is more than the union of the single column/row headers.
54 First, there might be less columns than fit into the view - in this case, right
55 beside the right-most column, there's still room which belongs to the column header
56 area, but is not occupied by any particular column header.<br/>
57 An equivalent statement holds for the row header area, if there are less rows than
60 Second, if the table control has both a row header and a column header,
61 the intersection between those both belongs to both the column header area and the
62 row header area, but not to any particular column or row header.
64 There are two flags specifying whether the to-be-painted area is part of the column
65 and/or row header area.
66 <ul><li>If both are <TRUE/>, the intersection of both areas is to be painted.</li>
67 <li>If ->_bIsColHeaderArea is <TRUE/> and ->_bIsRowHeaderArea is <FALSE/>,
68 then ->_rArea denotes the column header area <em>excluding</em> the
69 intersection between row and column header area.</li>
70 <li>Equivalently for ->_bIsColHeaderArea being <FALSE/> and ->_bIsRowHeaderArea
73 Note that it's not possible for both ->_bIsColHeaderArea and ->_bIsRowHeaderArea
74 to be <FALSE/> at the same time.
77 the device to paint onto
79 the area to paint into
80 @param _bIsColHeaderArea
81 <TRUE/> if and only if ->_rArea is part of the column header area.
82 @param _bIsRowHeaderArea
83 <TRUE/> if and only if ->_rArea is part of the row header area.
85 the style to be used for drawing
87 virtual void PaintHeaderArea(
88 OutputDevice
& _rDevice
, const Rectangle
& _rArea
,
89 bool _bIsColHeaderArea
, bool _bIsRowHeaderArea
,
90 const StyleSettings
& _rStyle
) = 0;
92 /** paints the header for a given column
95 the index of the column to paint
97 <TRUE/> if and only if the column whose column is to be painted
98 contains the active cell.
100 <TRUE/> if and only if the column whose column is to be painted
101 is selected currently.
103 denotes the device to paint onto
105 the are into which the column header should be painted
107 the style to be used for drawing
109 virtual void PaintColumnHeader( ColPos _nCol
, bool _bActive
, bool _bSelected
,
110 OutputDevice
& _rDevice
, const Rectangle
& _rArea
,
111 const StyleSettings
& _rStyle
) = 0;
113 /** prepares a row for painting
115 Painting a table means painting rows as necessary, in an increasing
116 order. The assumption is that retrieving data for two different rows
117 is (potentially) more expensive than retrieving data for two different
118 columns. Thus, the renderer will get the chance to "seek" to a certain
119 row, and then has to render all cells in this row, before another
120 row is going to be painted.
123 the row which is going to be painted. The renderer should
124 at least remember this row, since subsequent calls to
125 ->PaintRowHeader(), ->PaintCell(), and ->FinishRow() will
126 not pass this parameter again.
128 However, the renderer is also allowed to render any
129 cell-independent content of this row.
131 @param i_hasControlFocus
132 <TRUE/> if and only if the table control currently has the focus
134 <TRUE/> if and only if the row to be prepared is
137 denotes the device to paint onto
139 the are into which the row should be painted. This excludes
140 the row header area, if applicable.
142 the style to be used for drawing
144 virtual void PrepareRow( RowPos _nRow
, bool i_hasControlFocus
, bool _bSelected
,
145 OutputDevice
& _rDevice
, const Rectangle
& _rRowArea
,
146 const StyleSettings
& _rStyle
) = 0;
148 /** paints the header of a row
150 The row to be painted is denoted by the most recent call to
153 @param i_hasControlFocus
154 <TRUE/> if and only if the table control currently has the focus
156 Note that this flag is equal to the respective flag in the
157 previous ->PrepareRow call, it's passed here for convinience
160 <TRUE/> if and only if the row whose header cell is to be
161 painted is selected currently.
163 Note that this flag is equal to the respective flag in the
164 previous ->PrepareRow call, it's passed here for convinience
167 denotes the device to paint onto
169 the are into which the row header should be painted
171 the style to be used for drawing
173 virtual void PaintRowHeader( bool i_hasControlFocus
, bool _bSelected
,
174 OutputDevice
& _rDevice
, Rectangle
const & _rArea
,
175 StyleSettings
const & _rStyle
) = 0;
177 /** paints a certain cell
179 The row to be painted is denoted by the most recent call to
183 <TRUE/> if and only if the cell to be painted is
184 selected currently. This is the case if either
185 the row or the column of the cell is currently selected.
187 Note that this flag is equal to the respective flag in the
188 previous ->PrepareRow call, it's passed here for convinience
190 @param i_hasControlFocus
191 <TRUE/> if and only if the table control currently has the focus
193 Note that this flag is equal to the respective flag in the
194 previous ->PrepareRow call, it's passed here for convinience
197 denotes the device to paint onto
199 the are into which the cell should be painted
201 the style to be used for drawing
203 virtual void PaintCell( ColPos
const i_col
,
204 bool i_hasControlFocus
, bool _bSelected
,
205 OutputDevice
& _rDevice
, const Rectangle
& _rArea
,
206 const StyleSettings
& _rStyle
) = 0;
208 /** draws a cell cursor in the given rectangle
210 The cell cursor is used to indicate the active/current cell
213 virtual void ShowCellCursor( vcl::Window
& _rView
, const Rectangle
& _rCursorRect
) = 0;
215 /** hides the cell cursor previously drawn into the given rectangle
217 The cell cursor is used to indicate the active/current cell
220 virtual void HideCellCursor( vcl::Window
& _rView
, const Rectangle
& _rCursorRect
) = 0;
222 /** checks whether a given cell content fits into a given target area on a given device.
225 denotes the column which the cell content would be painted into. Your renderer implementation
226 would only need this parameter if rendering is done differently for different columns.
229 denotes the row which the cell content would be painted into. Your renderer implementation
230 would only need this parameter if rendering is done differently for different rows.
233 is <TRUE/> if and only if the renderer should assume the cell content would be painted for the active
237 is <TRUE/> if and only if the renderer should assume the cell content would be painted for a selected
240 @param i_targetDevice
241 denotes the target device for the assumed rendering operation
244 denotes the area within the target device for the assumed rendering operation.
247 <TRUE/> if and only if the given cell content could be rendered into the given device and the
250 virtual bool FitsIntoCell(
251 ::com::sun::star::uno::Any
const & i_cellContent
,
252 ColPos
const i_colPos
, RowPos
const i_rowPos
,
253 bool const i_active
, bool const i_selected
,
254 OutputDevice
& i_targetDevice
, Rectangle
const & i_targetArea
257 /** attempts to format the content of the given cell as string
260 the value for which an attempt for a string conversion should be made
262 the column position of the cell in question
264 the row position of the cell in question
266 the cell content, formatted as string
268 <TRUE/> if and only if the content could be formatted as string
270 virtual bool GetFormattedCellString(
271 ::com::sun::star::uno::Any
const & i_cellValue
,
272 ColPos
const i_colPos
, RowPos
const i_rowPos
,
273 OUString
& o_cellString
276 /// deletes the renderer instance
277 virtual ~ITableRenderer() { }
279 typedef std::shared_ptr
< ITableRenderer
> PTableRenderer
;
282 } } // namespace svt::table
285 #endif // INCLUDED_SVTOOLS_TABLE_TABLERENDERER_HXX
287 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */