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