1*01aa44aaSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*01aa44aaSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*01aa44aaSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*01aa44aaSAndrew Rist * distributed with this work for additional information 6*01aa44aaSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*01aa44aaSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*01aa44aaSAndrew Rist * "License"); you may not use this file except in compliance 9*01aa44aaSAndrew Rist * with the License. You may obtain a copy of the License at 10*01aa44aaSAndrew Rist * 11*01aa44aaSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*01aa44aaSAndrew Rist * 13*01aa44aaSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*01aa44aaSAndrew Rist * software distributed under the License is distributed on an 15*01aa44aaSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*01aa44aaSAndrew Rist * KIND, either express or implied. See the License for the 17*01aa44aaSAndrew Rist * specific language governing permissions and limitations 18*01aa44aaSAndrew Rist * under the License. 19*01aa44aaSAndrew Rist * 20*01aa44aaSAndrew Rist *************************************************************/ 21*01aa44aaSAndrew Rist 22*01aa44aaSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef SVTOOLS_INC_TABLE_TABLERENDERER_HXX 25cdf0e10cSrcweir #define SVTOOLS_INC_TABLE_TABLERENDERER_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <svtools/table/tabletypes.hxx> 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include <vcl/outdev.hxx> 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <boost/shared_ptr.hpp> 32cdf0e10cSrcweir 33cdf0e10cSrcweir //........................................................................ 34cdf0e10cSrcweir namespace svt { namespace table 35cdf0e10cSrcweir { 36cdf0e10cSrcweir //........................................................................ 37cdf0e10cSrcweir 38cdf0e10cSrcweir //==================================================================== 39cdf0e10cSrcweir //= ITableRenderer 40cdf0e10cSrcweir //==================================================================== 41cdf0e10cSrcweir /** interface to implement by components rendering a ->TableControl 42cdf0e10cSrcweir */ 43cdf0e10cSrcweir class SAL_NO_VTABLE ITableRenderer 44cdf0e10cSrcweir { 45cdf0e10cSrcweir public: 46cdf0e10cSrcweir 47cdf0e10cSrcweir /** paints a (part of) header area 48cdf0e10cSrcweir 49cdf0e10cSrcweir There are two header areas in a table control: 50cdf0e10cSrcweir <ul><li>The row containing all column headers, i.e. <em>above</em> all rows containing the data</li> 51cdf0e10cSrcweir <li>The column containing all row headers. i.e. <em>left of</em> all columns containing the data</li> 52cdf0e10cSrcweir </ul> 53cdf0e10cSrcweir 54cdf0e10cSrcweir A header area is more than the union of the single column/row headers. 55cdf0e10cSrcweir 56cdf0e10cSrcweir First, there might be less columns than fit into the view - in this case, right 57cdf0e10cSrcweir beside the right-most column, there's still room which belongs to the column header 58cdf0e10cSrcweir area, but is not occupied by any particular column header.<br/> 59cdf0e10cSrcweir An equivalent statement holds for the row header area, if there are less rows than 60cdf0e10cSrcweir fit into the view. 61cdf0e10cSrcweir 62cdf0e10cSrcweir Second, if the table control has both a row header and a column header, 63cdf0e10cSrcweir the intersection between those both belongs to both the column header area and the 64cdf0e10cSrcweir row header area, but not to any particular column or row header. 65cdf0e10cSrcweir 66cdf0e10cSrcweir There are two flags specifying whether the to-be-painted area is part of the column 67cdf0e10cSrcweir and/or row header area. 68cdf0e10cSrcweir <ul><li>If both are <TRUE/>, the intersection of both areas is to be painted.</li> 69cdf0e10cSrcweir <li>If ->_bIsColHeaderArea is <TRUE/> and ->_bIsRowHeaderArea is <FALSE/>, 70cdf0e10cSrcweir then ->_rArea denotes the column header area <em>excluding</em> the 71cdf0e10cSrcweir intersection between row and column header area.</li> 72cdf0e10cSrcweir <li>Equivalently for ->_bIsColHeaderArea being <FALSE/> and ->_bIsRowHeaderArea 73cdf0e10cSrcweir being <TRUE/></li> 74cdf0e10cSrcweir </ul> 75cdf0e10cSrcweir Note that it's not possible for both ->_bIsColHeaderArea and ->_bIsRowHeaderArea 76cdf0e10cSrcweir to be <FALSE/> at the same time. 77cdf0e10cSrcweir 78cdf0e10cSrcweir @param _rDevice 79cdf0e10cSrcweir the device to paint onto 80cdf0e10cSrcweir @param _rArea 81cdf0e10cSrcweir the area to paint into 82cdf0e10cSrcweir @param _bIsColHeaderArea 83cdf0e10cSrcweir <TRUE/> if and only if ->_rArea is part of the column header area. 84cdf0e10cSrcweir @param _bIsRowHeaderArea 85cdf0e10cSrcweir <TRUE/> if and only if ->_rArea is part of the row header area. 86cdf0e10cSrcweir @param _rStyle 87cdf0e10cSrcweir the style to be used for drawing 88cdf0e10cSrcweir */ 89cdf0e10cSrcweir virtual void PaintHeaderArea( 90cdf0e10cSrcweir OutputDevice& _rDevice, const Rectangle& _rArea, 91cdf0e10cSrcweir bool _bIsColHeaderArea, bool _bIsRowHeaderArea, 92cdf0e10cSrcweir const StyleSettings& _rStyle ) = 0; 93cdf0e10cSrcweir 94cdf0e10cSrcweir /** paints the header for a given column 95cdf0e10cSrcweir 96cdf0e10cSrcweir @param _nCol 97cdf0e10cSrcweir the index of the column to paint 98cdf0e10cSrcweir @param _bActive 99cdf0e10cSrcweir <TRUE/> if and only if the column whose column is to be painted 100cdf0e10cSrcweir contains the active cell. 101cdf0e10cSrcweir @param _bSelected 102cdf0e10cSrcweir <TRUE/> if and only if the column whose column is to be painted 103cdf0e10cSrcweir is selected currently. 104cdf0e10cSrcweir @param _rDevice 105cdf0e10cSrcweir denotes the device to paint onto 106cdf0e10cSrcweir @param _rArea 107cdf0e10cSrcweir the are into which the column header should be painted 108cdf0e10cSrcweir @param _rStyle 109cdf0e10cSrcweir the style to be used for drawing 110cdf0e10cSrcweir */ 111cdf0e10cSrcweir virtual void PaintColumnHeader( ColPos _nCol, bool _bActive, bool _bSelected, 112cdf0e10cSrcweir OutputDevice& _rDevice, const Rectangle& _rArea, 113cdf0e10cSrcweir const StyleSettings& _rStyle ) = 0; 114cdf0e10cSrcweir 115cdf0e10cSrcweir /** prepares a row for painting 116cdf0e10cSrcweir 117cdf0e10cSrcweir Painting a table means painting rows as necessary, in an increasing 118cdf0e10cSrcweir order. The assumption is that retrieving data for two different rows 119cdf0e10cSrcweir is (potentially) more expensive than retrieving data for two different 120cdf0e10cSrcweir columns. Thus, the renderer will get the chance to "seek" to a certain 121cdf0e10cSrcweir row, and then has to render all cells in this row, before another 122cdf0e10cSrcweir row is going to be painted. 123cdf0e10cSrcweir 124cdf0e10cSrcweir @param _nRow 125cdf0e10cSrcweir the row which is going to be painted. The renderer should 126cdf0e10cSrcweir at least remember this row, since subsequent calls to 127cdf0e10cSrcweir ->PaintRowHeader(), ->PaintCell(), and ->FinishRow() will 128cdf0e10cSrcweir not pass this parameter again. 129cdf0e10cSrcweir 130cdf0e10cSrcweir However, the renderer is also allowed to render any 131cdf0e10cSrcweir cell-independent content of this row. 132cdf0e10cSrcweir 133cdf0e10cSrcweir @param i_hasControlFocus 134cdf0e10cSrcweir <TRUE/> if and only if the table control currently has the focus 135cdf0e10cSrcweir @param _bSelected 136cdf0e10cSrcweir <TRUE/> if and only if the row to be prepared is 137cdf0e10cSrcweir selected currently. 138cdf0e10cSrcweir @param _rDevice 139cdf0e10cSrcweir denotes the device to paint onto 140cdf0e10cSrcweir @param _rRowArea 141cdf0e10cSrcweir the are into which the row should be painted. This excludes 142cdf0e10cSrcweir the row header area, if applicable. 143cdf0e10cSrcweir @param _rStyle 144cdf0e10cSrcweir the style to be used for drawing 145cdf0e10cSrcweir */ 146cdf0e10cSrcweir virtual void PrepareRow( RowPos _nRow, bool i_hasControlFocus, bool _bSelected, 147cdf0e10cSrcweir OutputDevice& _rDevice, const Rectangle& _rRowArea, 148cdf0e10cSrcweir const StyleSettings& _rStyle ) = 0; 149cdf0e10cSrcweir 150cdf0e10cSrcweir /** paints the header of a row 151cdf0e10cSrcweir 152cdf0e10cSrcweir The row to be painted is denoted by the most recent call to 153cdf0e10cSrcweir ->PrepareRow. 154cdf0e10cSrcweir 155cdf0e10cSrcweir @param i_hasControlFocus 156cdf0e10cSrcweir <TRUE/> if and only if the table control currently has the focus 157cdf0e10cSrcweir <br/> 158cdf0e10cSrcweir Note that this flag is equal to the respective flag in the 159cdf0e10cSrcweir previous ->PrepareRow call, it's passed here for convinience 160cdf0e10cSrcweir only. 161cdf0e10cSrcweir @param _bSelected 162cdf0e10cSrcweir <TRUE/> if and only if the row whose header cell is to be 163cdf0e10cSrcweir painted is selected currently. 164cdf0e10cSrcweir <br/> 165cdf0e10cSrcweir Note that this flag is equal to the respective flag in the 166cdf0e10cSrcweir previous ->PrepareRow call, it's passed here for convinience 167cdf0e10cSrcweir only. 168cdf0e10cSrcweir @param _rDevice 169cdf0e10cSrcweir denotes the device to paint onto 170cdf0e10cSrcweir @param _rArea 171cdf0e10cSrcweir the are into which the row header should be painted 172cdf0e10cSrcweir @param _rStyle 173cdf0e10cSrcweir the style to be used for drawing 174cdf0e10cSrcweir */ 175cdf0e10cSrcweir virtual void PaintRowHeader( bool i_hasControlFocus, bool _bSelected, 176cdf0e10cSrcweir OutputDevice& _rDevice, Rectangle const & _rArea, 177cdf0e10cSrcweir StyleSettings const & _rStyle ) = 0; 178cdf0e10cSrcweir 179cdf0e10cSrcweir /** paints a certain cell 180cdf0e10cSrcweir 181cdf0e10cSrcweir The row to be painted is denoted by the most recent call to 182cdf0e10cSrcweir ->PrepareRow. 183cdf0e10cSrcweir 184cdf0e10cSrcweir @param _bSelected 185cdf0e10cSrcweir <TRUE/> if and only if the cell to be painted is 186cdf0e10cSrcweir selected currently. This is the case if either 187cdf0e10cSrcweir the row or the column of the cell is currently selected. 188cdf0e10cSrcweir <br/> 189cdf0e10cSrcweir Note that this flag is equal to the respective flag in the 190cdf0e10cSrcweir previous ->PrepareRow call, it's passed here for convinience 191cdf0e10cSrcweir only. 192cdf0e10cSrcweir @param i_hasControlFocus 193cdf0e10cSrcweir <TRUE/> if and only if the table control currently has the focus 194cdf0e10cSrcweir <br/> 195cdf0e10cSrcweir Note that this flag is equal to the respective flag in the 196cdf0e10cSrcweir previous ->PrepareRow call, it's passed here for convinience 197cdf0e10cSrcweir only. 198cdf0e10cSrcweir @param _rDevice 199cdf0e10cSrcweir denotes the device to paint onto 200cdf0e10cSrcweir @param _rArea 201cdf0e10cSrcweir the are into which the cell should be painted 202cdf0e10cSrcweir @param _rStyle 203cdf0e10cSrcweir the style to be used for drawing 204cdf0e10cSrcweir */ 205cdf0e10cSrcweir virtual void PaintCell( ColPos const i_col, 206cdf0e10cSrcweir bool i_hasControlFocus, bool _bSelected, 207cdf0e10cSrcweir OutputDevice& _rDevice, const Rectangle& _rArea, 208cdf0e10cSrcweir const StyleSettings& _rStyle ) = 0; 209cdf0e10cSrcweir 210cdf0e10cSrcweir /** draws a cell cursor in the given rectangle 211cdf0e10cSrcweir 212cdf0e10cSrcweir The cell cursor is used to indicate the active/current cell 213cdf0e10cSrcweir of a table control. 214cdf0e10cSrcweir */ 215cdf0e10cSrcweir virtual void ShowCellCursor( Window& _rView, const Rectangle& _rCursorRect) = 0; 216cdf0e10cSrcweir 217cdf0e10cSrcweir /** hides the cell cursor previously drawn into the given rectangle 218cdf0e10cSrcweir 219cdf0e10cSrcweir The cell cursor is used to indicate the active/current cell 220cdf0e10cSrcweir of a table control. 221cdf0e10cSrcweir */ 222cdf0e10cSrcweir virtual void HideCellCursor( Window& _rView, const Rectangle& _rCursorRect) = 0; 223cdf0e10cSrcweir 224cdf0e10cSrcweir /** checks whether a given cell content fits into a given target area on a given device. 225cdf0e10cSrcweir 226cdf0e10cSrcweir @param i_colPos 227cdf0e10cSrcweir denotes the column which the cell content would be painted into. Your renderer implementation 228cdf0e10cSrcweir would only need this parameter if rendering is done differently for different columns. 229cdf0e10cSrcweir 230cdf0e10cSrcweir @param i_rowPos 231cdf0e10cSrcweir denotes the row which the cell content would be painted into. Your renderer implementation 232cdf0e10cSrcweir would only need this parameter if rendering is done differently for different rows. 233cdf0e10cSrcweir 234cdf0e10cSrcweir @param i_active 235cdf0e10cSrcweir is <TRUE/> if and only if the renderer should assume the cell content would be painted for the active 236cdf0e10cSrcweir cell. 237cdf0e10cSrcweir 238cdf0e10cSrcweir @param i_selected 239cdf0e10cSrcweir is <TRUE/> if and only if the renderer should assume the cell content would be painted for a selected 240cdf0e10cSrcweir cell. 241cdf0e10cSrcweir 242cdf0e10cSrcweir @param i_targetDevice 243cdf0e10cSrcweir denotes the target device for the assumed rendering operation 244cdf0e10cSrcweir 245cdf0e10cSrcweir @param i_targetArea 246cdf0e10cSrcweir denotes the area within the target device for the assumed rendering operation. 247cdf0e10cSrcweir 248cdf0e10cSrcweir @return 249cdf0e10cSrcweir <TRUE/> if and only if the given cell content could be rendered into the given device and the 250cdf0e10cSrcweir given area. 251cdf0e10cSrcweir */ 252cdf0e10cSrcweir virtual bool FitsIntoCell( 253cdf0e10cSrcweir ::com::sun::star::uno::Any const & i_cellContent, 254cdf0e10cSrcweir ColPos const i_colPos, RowPos const i_rowPos, 255cdf0e10cSrcweir bool const i_active, bool const i_selected, 256cdf0e10cSrcweir OutputDevice& i_targetDevice, Rectangle const & i_targetArea 257cdf0e10cSrcweir ) const = 0; 258cdf0e10cSrcweir 259cdf0e10cSrcweir /** attempts to format the content of the given cell as string 260cdf0e10cSrcweir 261cdf0e10cSrcweir @param i_cellValue 262cdf0e10cSrcweir the value for which an attempt for a string conversion should be made 263cdf0e10cSrcweir @param i_colPos 264cdf0e10cSrcweir the column position of the cell in question 265cdf0e10cSrcweir @param i_rowPos 266cdf0e10cSrcweir the row position of the cell in question 267cdf0e10cSrcweir @param o_cellString 268cdf0e10cSrcweir the cell content, formatted as string 269cdf0e10cSrcweir @return 270cdf0e10cSrcweir <TRUE/> if and only if the content could be formatted as string 271cdf0e10cSrcweir */ 272cdf0e10cSrcweir virtual bool GetFormattedCellString( 273cdf0e10cSrcweir ::com::sun::star::uno::Any const & i_cellValue, 274cdf0e10cSrcweir ColPos const i_colPos, RowPos const i_rowPos, 275cdf0e10cSrcweir ::rtl::OUString & o_cellString 276cdf0e10cSrcweir ) const = 0; 277cdf0e10cSrcweir 278cdf0e10cSrcweir /// deletes the renderer instance ~ITableRenderer()279cdf0e10cSrcweir virtual ~ITableRenderer() { } 280cdf0e10cSrcweir }; 281cdf0e10cSrcweir typedef ::boost::shared_ptr< ITableRenderer > PTableRenderer; 282cdf0e10cSrcweir 283cdf0e10cSrcweir //........................................................................ 284cdf0e10cSrcweir } } // namespace svt::table 285cdf0e10cSrcweir //........................................................................ 286cdf0e10cSrcweir 287cdf0e10cSrcweir #endif // SVTOOLS_INC_TABLE_TABLERENDERER_HXX 288