1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef SVTOOLS_INC_TABLE_GRIDTABLERENDERER_HXX 25 #define SVTOOLS_INC_TABLE_GRIDTABLERENDERER_HXX 26 27 #include <svtools/table/tablemodel.hxx> 28 29 #include <boost/scoped_ptr.hpp> 30 31 //........................................................................ 32 namespace svt { namespace table 33 { 34 //........................................................................ 35 36 struct GridTableRenderer_Impl; 37 38 //==================================================================== 39 //= GridTableRenderer 40 //==================================================================== 41 /** a default implementation for the ->ITableRenderer interface 42 43 This class is able to paint a table grid, table headers, and cell 44 backgrounds according to the selected/active state of cells. 45 */ 46 class GridTableRenderer : public ITableRenderer 47 { 48 private: 49 ::boost::scoped_ptr< GridTableRenderer_Impl > m_pImpl; 50 51 public: 52 /** creates a table renderer associated with the given model 53 54 @param _rModel 55 the model which should be rendered. The caller is responsible 56 for lifetime control, that is, the model instance must live 57 at least as long as the renderer instance lives 58 */ 59 GridTableRenderer( ITableModel& _rModel ); 60 ~GridTableRenderer(); 61 62 /** returns the index of the row currently being painted 63 64 According to the ->ITableRenderer interface, one call is made 65 to the renderer with a row to prepare (->PrepareRow()), and subsequent 66 calls do not carry the row index anymore, but are relative to the 67 row which has previously been prepared. 68 69 This method returns the index of the last row which has been prepared 70 */ 71 RowPos getCurrentRow() const; 72 73 /** determines whether or not to paint grid lines 74 */ 75 bool useGridLines() const; 76 77 /** controls whether or not to paint grid lines 78 */ 79 void useGridLines( bool const i_use ); 80 81 public: 82 // ITableRenderer overridables 83 virtual void PaintHeaderArea( 84 OutputDevice& _rDevice, const Rectangle& _rArea, 85 bool _bIsColHeaderArea, bool _bIsRowHeaderArea, 86 const StyleSettings& _rStyle ); 87 virtual void PaintColumnHeader( ColPos _nCol, bool _bActive, bool _bSelected, 88 OutputDevice& _rDevice, const Rectangle& _rArea, 89 const StyleSettings& _rStyle ); 90 virtual void PrepareRow( RowPos _nRow, bool i_hasControlFocus, bool _bSelected, 91 OutputDevice& _rDevice, const Rectangle& _rRowArea, 92 const StyleSettings& _rStyle ); 93 virtual void PaintRowHeader( 94 bool i_hasControlFocus, bool _bSelected, 95 OutputDevice& _rDevice, const Rectangle& _rArea, 96 const StyleSettings& _rStyle ); 97 virtual void PaintCell( ColPos const i_col, 98 bool i_hasControlFocus, bool _bSelected, 99 OutputDevice& _rDevice, const Rectangle& _rArea, 100 const StyleSettings& _rStyle ); 101 virtual void ShowCellCursor( Window& _rView, const Rectangle& _rCursorRect); 102 virtual void HideCellCursor( Window& _rView, const Rectangle& _rCursorRect); 103 virtual bool FitsIntoCell( 104 ::com::sun::star::uno::Any const & i_cellContent, 105 ColPos const i_colPos, RowPos const i_rowPos, 106 bool const i_active, bool const i_selected, 107 OutputDevice& i_targetDevice, Rectangle const & i_targetArea 108 ) const; 109 virtual bool GetFormattedCellString( 110 ::com::sun::star::uno::Any const & i_cellValue, 111 ColPos const i_colPos, RowPos const i_rowPos, 112 ::rtl::OUString & o_cellString 113 ) const; 114 115 private: 116 struct CellRenderContext; 117 118 void impl_paintCellContent( 119 CellRenderContext const & i_context 120 ); 121 void impl_paintCellImage( 122 CellRenderContext const & i_context, 123 Image const & i_image 124 ); 125 void impl_paintCellText( 126 CellRenderContext const & i_context, 127 ::rtl::OUString const & i_text 128 ); 129 }; 130 //........................................................................ 131 } } // namespace svt::table 132 //........................................................................ 133 134 #endif // SVTOOLS_INC_TABLE_GRIDTABLERENDERER_HXX 135