1 /************************************************************************* 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * 4 * Copyright 2000, 2010 Oracle and/or its affiliates. 5 * 6 * OpenOffice.org - a multi-platform office productivity suite 7 * 8 * This file is part of OpenOffice.org. 9 * 10 * OpenOffice.org is free software: you can redistribute it and/or modify 11 * it under the terms of the GNU Lesser General Public License version 3 12 * only, as published by the Free Software Foundation. 13 * 14 * OpenOffice.org is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU Lesser General Public License version 3 for more details 18 * (a copy is included in the LICENSE file that accompanied this code). 19 * 20 * You should have received a copy of the GNU Lesser General Public License 21 * version 3 along with OpenOffice.org. If not, see 22 * <http://www.openoffice.org/license.html> 23 * for a copy of the LGPLv3 License. 24 * 25 ************************************************************************/ 26 27 #ifndef SVTOOLS_INC_TABLE_GRIDTABLERENDERER_HXX 28 #define SVTOOLS_INC_TABLE_GRIDTABLERENDERER_HXX 29 30 #include <svtools/table/tablemodel.hxx> 31 32 #include <boost/scoped_ptr.hpp> 33 34 //........................................................................ 35 namespace svt { namespace table 36 { 37 //........................................................................ 38 39 struct GridTableRenderer_Impl; 40 41 //==================================================================== 42 //= GridTableRenderer 43 //==================================================================== 44 /** a default implementation for the ->ITableRenderer interface 45 46 This class is able to paint a table grid, table headers, and cell 47 backgrounds according to the selected/active state of cells. 48 */ 49 class GridTableRenderer : public ITableRenderer 50 { 51 private: 52 ::boost::scoped_ptr< GridTableRenderer_Impl > m_pImpl; 53 54 public: 55 /** creates a table renderer associated with the given model 56 57 @param _rModel 58 the model which should be rendered. The caller is responsible 59 for lifetime control, that is, the model instance must live 60 at least as long as the renderer instance lives 61 */ 62 GridTableRenderer( ITableModel& _rModel ); 63 ~GridTableRenderer(); 64 65 /** returns the index of the row currently being painted 66 67 According to the ->ITableRenderer interface, one call is made 68 to the renderer with a row to prepare (->PrepareRow()), and subsequent 69 calls do not carry the row index anymore, but are relative to the 70 row which has previously been prepared. 71 72 This method returns the index of the last row which has been prepared 73 */ 74 RowPos getCurrentRow() const; 75 76 /** determines whether or not to paint grid lines 77 */ 78 bool useGridLines() const; 79 80 /** controls whether or not to paint grid lines 81 */ 82 void useGridLines( bool const i_use ); 83 84 public: 85 // ITableRenderer overridables 86 virtual void PaintHeaderArea( 87 OutputDevice& _rDevice, const Rectangle& _rArea, 88 bool _bIsColHeaderArea, bool _bIsRowHeaderArea, 89 const StyleSettings& _rStyle ); 90 virtual void PaintColumnHeader( ColPos _nCol, bool _bActive, bool _bSelected, 91 OutputDevice& _rDevice, const Rectangle& _rArea, 92 const StyleSettings& _rStyle ); 93 virtual void PrepareRow( RowPos _nRow, bool i_hasControlFocus, bool _bSelected, 94 OutputDevice& _rDevice, const Rectangle& _rRowArea, 95 const StyleSettings& _rStyle ); 96 virtual void PaintRowHeader( 97 bool i_hasControlFocus, bool _bSelected, 98 OutputDevice& _rDevice, const Rectangle& _rArea, 99 const StyleSettings& _rStyle ); 100 virtual void PaintCell( ColPos const i_col, 101 bool i_hasControlFocus, bool _bSelected, 102 OutputDevice& _rDevice, const Rectangle& _rArea, 103 const StyleSettings& _rStyle ); 104 virtual void ShowCellCursor( Window& _rView, const Rectangle& _rCursorRect); 105 virtual void HideCellCursor( Window& _rView, const Rectangle& _rCursorRect); 106 virtual bool FitsIntoCell( 107 ::com::sun::star::uno::Any const & i_cellContent, 108 ColPos const i_colPos, RowPos const i_rowPos, 109 bool const i_active, bool const i_selected, 110 OutputDevice& i_targetDevice, Rectangle const & i_targetArea 111 ) const; 112 virtual bool GetFormattedCellString( 113 ::com::sun::star::uno::Any const & i_cellValue, 114 ColPos const i_colPos, RowPos const i_rowPos, 115 ::rtl::OUString & o_cellString 116 ) const; 117 118 private: 119 struct CellRenderContext; 120 121 void impl_paintCellContent( 122 CellRenderContext const & i_context 123 ); 124 void impl_paintCellImage( 125 CellRenderContext const & i_context, 126 Image const & i_image 127 ); 128 void impl_paintCellText( 129 CellRenderContext const & i_context, 130 ::rtl::OUString const & i_text 131 ); 132 }; 133 //........................................................................ 134 } } // namespace svt::table 135 //........................................................................ 136 137 #endif // SVTOOLS_INC_TABLE_GRIDTABLERENDERER_HXX 138