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_GRIDTABLERENDERER_HXX
25cdf0e10cSrcweir #define SVTOOLS_INC_TABLE_GRIDTABLERENDERER_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <svtools/table/tablemodel.hxx>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <boost/scoped_ptr.hpp>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir //........................................................................
32cdf0e10cSrcweir namespace svt { namespace table
33cdf0e10cSrcweir {
34cdf0e10cSrcweir //........................................................................
35cdf0e10cSrcweir 
36cdf0e10cSrcweir     struct GridTableRenderer_Impl;
37cdf0e10cSrcweir 
38cdf0e10cSrcweir     //====================================================================
39cdf0e10cSrcweir 	//= GridTableRenderer
40cdf0e10cSrcweir 	//====================================================================
41cdf0e10cSrcweir     /** a default implementation for the ->ITableRenderer interface
42cdf0e10cSrcweir 
43cdf0e10cSrcweir         This class is able to paint a table grid, table headers, and cell
44cdf0e10cSrcweir         backgrounds according to the selected/active state of cells.
45cdf0e10cSrcweir     */
46cdf0e10cSrcweir     class GridTableRenderer : public ITableRenderer
47cdf0e10cSrcweir     {
48cdf0e10cSrcweir     private:
49cdf0e10cSrcweir         ::boost::scoped_ptr< GridTableRenderer_Impl >   m_pImpl;
50cdf0e10cSrcweir 
51cdf0e10cSrcweir     public:
52cdf0e10cSrcweir         /** creates a table renderer associated with the given model
53cdf0e10cSrcweir 
54cdf0e10cSrcweir             @param _rModel
55cdf0e10cSrcweir                 the model which should be rendered. The caller is responsible
56cdf0e10cSrcweir                 for lifetime control, that is, the model instance must live
57cdf0e10cSrcweir                 at least as long as the renderer instance lives
58cdf0e10cSrcweir         */
59cdf0e10cSrcweir         GridTableRenderer( ITableModel& _rModel );
60cdf0e10cSrcweir         ~GridTableRenderer();
61cdf0e10cSrcweir 
62cdf0e10cSrcweir         /** returns the index of the row currently being painted
63cdf0e10cSrcweir 
64cdf0e10cSrcweir             According to the ->ITableRenderer interface, one call is made
65cdf0e10cSrcweir             to the renderer with a row to prepare (->PrepareRow()), and subsequent
66cdf0e10cSrcweir             calls do not carry the row index anymore, but are relative to the
67cdf0e10cSrcweir             row which has previously been prepared.
68cdf0e10cSrcweir 
69cdf0e10cSrcweir             This method returns the index of the last row which has been prepared
70cdf0e10cSrcweir         */
71cdf0e10cSrcweir         RowPos  getCurrentRow() const;
72cdf0e10cSrcweir 
73cdf0e10cSrcweir         /** determines whether or not to paint grid lines
74cdf0e10cSrcweir         */
75cdf0e10cSrcweir         bool    useGridLines() const;
76cdf0e10cSrcweir 
77cdf0e10cSrcweir         /** controls whether or not to paint grid lines
78cdf0e10cSrcweir         */
79cdf0e10cSrcweir         void    useGridLines( bool const i_use );
80cdf0e10cSrcweir 
81cdf0e10cSrcweir     public:
82cdf0e10cSrcweir         // ITableRenderer overridables
83cdf0e10cSrcweir         virtual void    PaintHeaderArea(
84cdf0e10cSrcweir                             OutputDevice& _rDevice, const Rectangle& _rArea,
85cdf0e10cSrcweir                             bool _bIsColHeaderArea, bool _bIsRowHeaderArea,
86cdf0e10cSrcweir                             const StyleSettings& _rStyle );
87cdf0e10cSrcweir         virtual void    PaintColumnHeader( ColPos _nCol, bool _bActive, bool _bSelected,
88cdf0e10cSrcweir                             OutputDevice& _rDevice, const Rectangle& _rArea,
89cdf0e10cSrcweir                             const StyleSettings& _rStyle );
90cdf0e10cSrcweir         virtual void    PrepareRow( RowPos _nRow, bool i_hasControlFocus, bool _bSelected,
91cdf0e10cSrcweir                             OutputDevice& _rDevice, const Rectangle& _rRowArea,
92cdf0e10cSrcweir                             const StyleSettings& _rStyle );
93cdf0e10cSrcweir         virtual void    PaintRowHeader(
94cdf0e10cSrcweir                             bool i_hasControlFocus, bool _bSelected,
95cdf0e10cSrcweir                             OutputDevice& _rDevice, const Rectangle& _rArea,
96cdf0e10cSrcweir 							const StyleSettings& _rStyle );
97cdf0e10cSrcweir         virtual void    PaintCell( ColPos const i_col,
98cdf0e10cSrcweir                             bool i_hasControlFocus, bool _bSelected,
99cdf0e10cSrcweir                             OutputDevice& _rDevice, const Rectangle& _rArea,
100cdf0e10cSrcweir 			                const StyleSettings& _rStyle );
101cdf0e10cSrcweir         virtual void    ShowCellCursor( Window& _rView, const Rectangle& _rCursorRect);
102cdf0e10cSrcweir         virtual void    HideCellCursor( Window& _rView, const Rectangle& _rCursorRect);
103cdf0e10cSrcweir         virtual bool    FitsIntoCell(
104cdf0e10cSrcweir                             ::com::sun::star::uno::Any const & i_cellContent,
105cdf0e10cSrcweir                             ColPos const i_colPos, RowPos const i_rowPos,
106cdf0e10cSrcweir                             bool const i_active, bool const i_selected,
107cdf0e10cSrcweir                             OutputDevice& i_targetDevice, Rectangle const & i_targetArea
108cdf0e10cSrcweir                         ) const;
109cdf0e10cSrcweir         virtual bool    GetFormattedCellString(
110cdf0e10cSrcweir                             ::com::sun::star::uno::Any const & i_cellValue,
111cdf0e10cSrcweir                             ColPos const i_colPos, RowPos const i_rowPos,
112cdf0e10cSrcweir                             ::rtl::OUString & o_cellString
113cdf0e10cSrcweir                         ) const;
114cdf0e10cSrcweir 
115cdf0e10cSrcweir     private:
116cdf0e10cSrcweir         struct CellRenderContext;
117cdf0e10cSrcweir 
118cdf0e10cSrcweir         void    impl_paintCellContent(
119cdf0e10cSrcweir                         CellRenderContext const & i_context
120cdf0e10cSrcweir                    );
121cdf0e10cSrcweir         void    impl_paintCellImage(
122cdf0e10cSrcweir                         CellRenderContext const & i_context,
123cdf0e10cSrcweir                         Image const & i_image
124cdf0e10cSrcweir                    );
125cdf0e10cSrcweir         void    impl_paintCellText(
126cdf0e10cSrcweir                         CellRenderContext const & i_context,
127cdf0e10cSrcweir                         ::rtl::OUString const & i_text
128cdf0e10cSrcweir                    );
129cdf0e10cSrcweir     };
130cdf0e10cSrcweir //........................................................................
131cdf0e10cSrcweir } } // namespace svt::table
132cdf0e10cSrcweir //........................................................................
133cdf0e10cSrcweir 
134cdf0e10cSrcweir #endif // SVTOOLS_INC_TABLE_GRIDTABLERENDERER_HXX
135