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 <rtl/ustring.hxx>
29 namespace com :: sun :: star :: uno
{ class Any
; }
30 namespace tools
{ class Rectangle
; }
31 namespace vcl
{ class Window
; }
36 typedef OutputDevice RenderContext
;
40 namespace svt
{ namespace table
46 /** interface to implement by components rendering a ->TableControl
48 class SAL_NO_VTABLE ITableRenderer
52 /** paints a (part of) header area
54 There are two header areas in a table control:
55 <ul><li>The row containing all column headers, i.e. <em>above</em> all rows containing the data</li>
56 <li>The column containing all row headers. i.e. <em>left of</em> all columns containing the data</li>
59 A header area is more than the union of the single column/row headers.
61 First, there might be less columns than fit into the view - in this case, right
62 beside the right-most column, there's still room which belongs to the column header
63 area, but is not occupied by any particular column header.<br/>
64 An equivalent statement holds for the row header area, if there are less rows than
67 Second, if the table control has both a row header and a column header,
68 the intersection between those both belongs to both the column header area and the
69 row header area, but not to any particular column or row header.
71 There are two flags specifying whether the to-be-painted area is part of the column
72 and/or row header area.
73 <ul><li>If both are <TRUE/>, the intersection of both areas is to be painted.</li>
74 <li>If ->_bIsColHeaderArea is <TRUE/> and ->_bIsRowHeaderArea is <FALSE/>,
75 then ->_rArea denotes the column header area <em>excluding</em> the
76 intersection between row and column header area.</li>
77 <li>Equivalently for ->_bIsColHeaderArea being <FALSE/> and ->_bIsRowHeaderArea
80 Note that it's not possible for both ->_bIsColHeaderArea and ->_bIsRowHeaderArea
81 to be <FALSE/> at the same time.
84 the device to paint onto
86 the area to paint into
87 @param _bIsColHeaderArea
88 <TRUE/> if and only if ->_rArea is part of the column header area.
89 @param _bIsRowHeaderArea
90 <TRUE/> if and only if ->_rArea is part of the row header area.
92 the style to be used for drawing
94 virtual void PaintHeaderArea(
95 vcl::RenderContext
& _rDevice
, const tools::Rectangle
& _rArea
,
96 bool _bIsColHeaderArea
, bool _bIsRowHeaderArea
,
97 const StyleSettings
& _rStyle
) = 0;
99 /** paints the header for a given column
102 the index of the column to paint
104 <TRUE/> if and only if the column whose column is to be painted
105 contains the active cell.
107 denotes the device to paint onto
109 the are into which the column header should be painted
111 the style to be used for drawing
113 virtual void PaintColumnHeader( ColPos _nCol
, bool _bActive
,
114 vcl::RenderContext
& _rDevice
, const tools::Rectangle
& _rArea
,
115 const StyleSettings
& _rStyle
) = 0;
117 /** prepares a row for painting
119 Painting a table means painting rows as necessary, in an increasing
120 order. The assumption is that retrieving data for two different rows
121 is (potentially) more expensive than retrieving data for two different
122 columns. Thus, the renderer will get the chance to "seek" to a certain
123 row, and then has to render all cells in this row, before another
124 row is going to be painted.
127 the row which is going to be painted. The renderer should
128 at least remember this row, since subsequent calls to
129 ->PaintRowHeader(), ->PaintCell(), and ->FinishRow() will
130 not pass this parameter again.
132 However, the renderer is also allowed to render any
133 cell-independent content of this row.
135 @param i_hasControlFocus
136 <TRUE/> if and only if the table control currently has the focus
138 <TRUE/> if and only if the row to be prepared is
141 denotes the device to paint onto
143 the are into which the row should be painted. This excludes
144 the row header area, if applicable.
146 the style to be used for drawing
148 virtual void PrepareRow( RowPos _nRow
, bool i_hasControlFocus
, bool _bSelected
,
149 vcl::RenderContext
& _rDevice
, const tools::Rectangle
& _rRowArea
,
150 const StyleSettings
& _rStyle
) = 0;
152 /** paints the header of a row
154 The row to be painted is denoted by the most recent call to
157 @param i_hasControlFocus
158 <TRUE/> if and only if the table control currently has the focus
160 Note that this flag is equal to the respective flag in the
161 previous ->PrepareRow call, it's passed here for convenience
164 <TRUE/> if and only if the row whose header cell is to be
165 painted is selected currently.
167 Note that this flag is equal to the respective flag in the
168 previous ->PrepareRow call, it's passed here for convenience
171 denotes the device to paint onto
173 the are into which the row header should be painted
175 the style to be used for drawing
177 virtual void PaintRowHeader( bool i_hasControlFocus
, bool _bSelected
,
178 vcl::RenderContext
& _rDevice
, tools::Rectangle
const & _rArea
,
179 StyleSettings
const & _rStyle
) = 0;
181 /** paints a certain cell
183 The row to be painted is denoted by the most recent call to
187 <TRUE/> if and only if the cell to be painted is
188 selected currently. This is the case if either
189 the row or the column of the cell is currently selected.
191 Note that this flag is equal to the respective flag in the
192 previous ->PrepareRow call, it's passed here for convenience
194 @param i_hasControlFocus
195 <TRUE/> if and only if the table control currently has the focus
197 Note that this flag is equal to the respective flag in the
198 previous ->PrepareRow call, it's passed here for convenience
201 denotes the device to paint onto
203 the are into which the cell should be painted
205 the style to be used for drawing
207 virtual void PaintCell( ColPos
const i_col
,
208 bool i_hasControlFocus
, bool _bSelected
,
209 vcl::RenderContext
& _rDevice
, const tools::Rectangle
& _rArea
,
210 const StyleSettings
& _rStyle
) = 0;
212 /** draws a cell cursor in the given rectangle
214 The cell cursor is used to indicate the active/current cell
217 virtual void ShowCellCursor( vcl::Window
& _rView
, const tools::Rectangle
& _rCursorRect
) = 0;
219 /** hides the cell cursor previously drawn into the given rectangle
221 The cell cursor is used to indicate the active/current cell
224 virtual void HideCellCursor( vcl::Window
& _rView
, const tools::Rectangle
& _rCursorRect
) = 0;
226 /** checks whether a given cell content fits into a given target area on a given device.
228 @param i_targetDevice
229 denotes the target device for the assumed rendering operation
232 denotes the area within the target device for the assumed rendering operation.
235 <TRUE/> if and only if the given cell content could be rendered into the given device and the
238 virtual bool FitsIntoCell(
239 css::uno::Any
const & i_cellContent
,
240 OutputDevice
& i_targetDevice
, tools::Rectangle
const & i_targetArea
243 /** attempts to format the content of the given cell as string
246 the value for which an attempt for a string conversion should be made
248 the cell content, formatted as string
250 <TRUE/> if and only if the content could be formatted as string
252 virtual bool GetFormattedCellString(
253 css::uno::Any
const & i_cellValue
,
254 OUString
& o_cellString
257 /// deletes the renderer instance
258 virtual ~ITableRenderer() { }
260 typedef std::shared_ptr
< ITableRenderer
> PTableRenderer
;
263 } } // namespace svt::table
266 #endif // INCLUDED_SVTOOLS_TABLE_TABLERENDERER_HXX
268 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */