Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 : : *
5 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
6 : : *
7 : : * OpenOffice.org - a multi-platform office productivity suite
8 : : *
9 : : * This file is part of OpenOffice.org.
10 : : *
11 : : * OpenOffice.org is free software: you can redistribute it and/or modify
12 : : * it under the terms of the GNU Lesser General Public License version 3
13 : : * only, as published by the Free Software Foundation.
14 : : *
15 : : * OpenOffice.org is distributed in the hope that it will be useful,
16 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 : : * GNU Lesser General Public License version 3 for more details
19 : : * (a copy is included in the LICENSE file that accompanied this code).
20 : : *
21 : : * You should have received a copy of the GNU Lesser General Public License
22 : : * version 3 along with OpenOffice.org. If not, see
23 : : * <http://www.openoffice.org/license.html>
24 : : * for a copy of the LGPLv3 License.
25 : : *
26 : : ************************************************************************/
27 : :
28 : : #ifndef SVTOOLS_INC_TABLE_TABLERENDERER_HXX
29 : : #define SVTOOLS_INC_TABLE_TABLERENDERER_HXX
30 : :
31 : : #include <svtools/table/tabletypes.hxx>
32 : :
33 : : #include <vcl/outdev.hxx>
34 : :
35 : : #include <boost/shared_ptr.hpp>
36 : :
37 : : //........................................................................
38 : : namespace svt { namespace table
39 : : {
40 : : //........................................................................
41 : :
42 : : //====================================================================
43 : : //= ITableRenderer
44 : : //====================================================================
45 : : /** interface to implement by components rendering a ->TableControl
46 : : */
47 : 0 : class SAL_NO_VTABLE ITableRenderer
48 : : {
49 : : public:
50 : :
51 : : /** paints a (part of) header area
52 : :
53 : : There are two header areas in a table control:
54 : : <ul><li>The row containing all column headers, i.e. <em>above</em> all rows containing the data</li>
55 : : <li>The column containing all row headers. i.e. <em>left of</em> all columns containing the data</li>
56 : : </ul>
57 : :
58 : : A header area is more than the union of the single column/row headers.
59 : :
60 : : First, there might be less columns than fit into the view - in this case, right
61 : : beside the right-most column, there's still room which belongs to the column header
62 : : area, but is not occupied by any particular column header.<br/>
63 : : An equivalent statement holds for the row header area, if there are less rows than
64 : : fit into the view.
65 : :
66 : : Second, if the table control has both a row header and a column header,
67 : : the intersection between those both belongs to both the column header area and the
68 : : row header area, but not to any particular column or row header.
69 : :
70 : : There are two flags specifying whether the to-be-painted area is part of the column
71 : : and/or row header area.
72 : : <ul><li>If both are <TRUE/>, the intersection of both areas is to be painted.</li>
73 : : <li>If ->_bIsColHeaderArea is <TRUE/> and ->_bIsRowHeaderArea is <FALSE/>,
74 : : then ->_rArea denotes the column header area <em>excluding</em> the
75 : : intersection between row and column header area.</li>
76 : : <li>Equivalently for ->_bIsColHeaderArea being <FALSE/> and ->_bIsRowHeaderArea
77 : : being <TRUE/></li>
78 : : </ul>
79 : : Note that it's not possible for both ->_bIsColHeaderArea and ->_bIsRowHeaderArea
80 : : to be <FALSE/> at the same time.
81 : :
82 : : @param _rDevice
83 : : the device to paint onto
84 : : @param _rArea
85 : : the area to paint into
86 : : @param _bIsColHeaderArea
87 : : <TRUE/> if and only if ->_rArea is part of the column header area.
88 : : @param _bIsRowHeaderArea
89 : : <TRUE/> if and only if ->_rArea is part of the row header area.
90 : : @param _rStyle
91 : : the style to be used for drawing
92 : : */
93 : : virtual void PaintHeaderArea(
94 : : OutputDevice& _rDevice, const Rectangle& _rArea,
95 : : bool _bIsColHeaderArea, bool _bIsRowHeaderArea,
96 : : const StyleSettings& _rStyle ) = 0;
97 : :
98 : : /** paints the header for a given column
99 : :
100 : : @param _nCol
101 : : the index of the column to paint
102 : : @param _bActive
103 : : <TRUE/> if and only if the column whose column is to be painted
104 : : contains the active cell.
105 : : @param _bSelected
106 : : <TRUE/> if and only if the column whose column is to be painted
107 : : is selected currently.
108 : : @param _rDevice
109 : : denotes the device to paint onto
110 : : @param _rArea
111 : : the are into which the column header should be painted
112 : : @param _rStyle
113 : : the style to be used for drawing
114 : : */
115 : : virtual void PaintColumnHeader( ColPos _nCol, bool _bActive, bool _bSelected,
116 : : OutputDevice& _rDevice, const Rectangle& _rArea,
117 : : const StyleSettings& _rStyle ) = 0;
118 : :
119 : : /** prepares a row for painting
120 : :
121 : : Painting a table means painting rows as necessary, in an increasing
122 : : order. The assumption is that retrieving data for two different rows
123 : : is (potentially) more expensive than retrieving data for two different
124 : : columns. Thus, the renderer will get the chance to "seek" to a certain
125 : : row, and then has to render all cells in this row, before another
126 : : row is going to be painted.
127 : :
128 : : @param _nRow
129 : : the row which is going to be painted. The renderer should
130 : : at least remember this row, since subsequent calls to
131 : : ->PaintRowHeader(), ->PaintCell(), and ->FinishRow() will
132 : : not pass this parameter again.
133 : :
134 : : However, the renderer is also allowed to render any
135 : : cell-independent content of this row.
136 : :
137 : : @param _bActive
138 : : <TRUE/> if and only if the row to be painted contains the
139 : : currently active cell.
140 : : @param _bSelected
141 : : <TRUE/> if and only if the row to be prepared is
142 : : selected currently.
143 : : @param _rDevice
144 : : denotes the device to paint onto
145 : : @param _rRowArea
146 : : the are into which the row should be painted. This excludes
147 : : the row header area, if applicable.
148 : : @param _rStyle
149 : : the style to be used for drawing
150 : : */
151 : : virtual void PrepareRow( RowPos _nRow, bool _bActive, bool _bSelected,
152 : : OutputDevice& _rDevice, const Rectangle& _rRowArea,
153 : : const StyleSettings& _rStyle ) = 0;
154 : :
155 : : /** paints the header of a row
156 : :
157 : : The row to be painted is denoted by the most recent call to
158 : : ->PrepareRow.
159 : :
160 : : @param _bActive
161 : : <TRUE/> if and only if the row to be painted contains the
162 : : currently active cell.
163 : : <br/>
164 : : Note that this flag is equal to the respective flag in the
165 : : previous ->PrepareRow call, it's passed here for convinience
166 : : only.
167 : : @param _bSelected
168 : : <TRUE/> if and only if the row whose header cell is to be
169 : : painted is selected currently.
170 : : <br/>
171 : : Note that this flag is equal to the respective flag in the
172 : : previous ->PrepareRow call, it's passed here for convinience
173 : : only.
174 : : @param _rDevice
175 : : denotes the device to paint onto
176 : : @param _rArea
177 : : the are into which the row header should be painted
178 : : @param _rStyle
179 : : the style to be used for drawing
180 : : */
181 : : virtual void PaintRowHeader( bool _bActive, bool _bSelected,
182 : : OutputDevice& _rDevice, const Rectangle& _rArea,
183 : : const StyleSettings& _rStyle ) = 0;
184 : :
185 : : /** paints a certain cell
186 : :
187 : : The row to be painted is denoted by the most recent call to
188 : : ->PrepareRow.
189 : :
190 : : @param _bSelected
191 : : <TRUE/> if and only if the cell to be painted is
192 : : selected currently. This is the case if either
193 : : the row or the column of the cell is currently selected.
194 : : <br/>
195 : : Note that this flag is equal to the respective flag in the
196 : : previous ->PrepareRow call, it's passed here for convinience
197 : : only.
198 : : @param _bActive
199 : : <TRUE/> if the cell is currently active.
200 : : <br/>
201 : : Note that this flag is equal to the respective flag in the
202 : : previous ->PrepareRow call, it's passed here for convinience
203 : : only.
204 : : @param _rDevice
205 : : denotes the device to paint onto
206 : : @param _rArea
207 : : the are into which the cell should be painted
208 : : @param _rStyle
209 : : the style to be used for drawing
210 : : */
211 : : virtual void PaintCell( ColPos const i_col,
212 : : bool _bActive, bool _bSelected,
213 : : OutputDevice& _rDevice, const Rectangle& _rArea,
214 : : const StyleSettings& _rStyle ) = 0;
215 : :
216 : : /** draws a cell cursor in the given rectangle
217 : :
218 : : The cell cursor is used to indicate the active/current cell
219 : : of a table control.
220 : : */
221 : : virtual void ShowCellCursor( Window& _rView, const Rectangle& _rCursorRect) = 0;
222 : :
223 : : /** hides the cell cursor previously drawn into the given rectangle
224 : :
225 : : The cell cursor is used to indicate the active/current cell
226 : : of a table control.
227 : : */
228 : : virtual void HideCellCursor( Window& _rView, const Rectangle& _rCursorRect) = 0;
229 : :
230 : : /** checks whether a given cell content fits into a given target area on a given device.
231 : :
232 : : @param i_colPos
233 : : denotes the column which the cell content would be painted into. Your renderer implementation
234 : : would only need this parameter if rendering is done differently for different columns.
235 : :
236 : : @param i_rowPos
237 : : denotes the row which the cell content would be painted into. Your renderer implementation
238 : : would only need this parameter if rendering is done differently for different rows.
239 : :
240 : : @param i_active
241 : : is <TRUE/> if and only if the renderer should assume the cell content would be painted for the active
242 : : cell.
243 : :
244 : : @param i_selected
245 : : is <TRUE/> if and only if the renderer should assume the cell content would be painted for a selected
246 : : cell.
247 : :
248 : : @param i_targetDevice
249 : : denotes the target device for the assumed rendering operation
250 : :
251 : : @param i_targetArea
252 : : denotes the area within the target device for the assumed rendering operation.
253 : :
254 : : @return
255 : : <TRUE/> if and only if the given cell content could be rendered into the given device and the
256 : : given area.
257 : : */
258 : : virtual bool FitsIntoCell(
259 : : ::com::sun::star::uno::Any const & i_cellContent,
260 : : ColPos const i_colPos, RowPos const i_rowPos,
261 : : bool const i_active, bool const i_selected,
262 : : OutputDevice& i_targetDevice, Rectangle const & i_targetArea
263 : : ) = 0;
264 : :
265 : : /// deletes the renderer instance
266 [ # # ]: 0 : virtual ~ITableRenderer() { }
267 : : };
268 : : typedef ::boost::shared_ptr< ITableRenderer > PTableRenderer;
269 : :
270 : : //........................................................................
271 : : } } // namespace svt::table
272 : : //........................................................................
273 : :
274 : : #endif // SVTOOLS_INC_TABLE_TABLERENDERER_HXX
275 : :
276 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|