xref: /trunk/main/sw/source/core/inc/drawdev.hxx (revision 1d2dbeb0)
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 _DRAWDEV_HXX
25 #define _DRAWDEV_HXX
26 
27 #include "swrect.hxx"
28 
29 #ifndef _OUTDEV_HXX //autogen
30 #include <vcl/outdev.hxx>
31 #endif
32 
33 /*************************************************************************
34  *							class SwDrawDev
35  *
36  * Alle Draw-Methoden werden um den Offset *pPos verschoben.
37  *************************************************************************/
38 
39 class SwDrawDev
40 {
41 	OutputDevice  *pOut;
42 	const Point *pPos;
43 
44 public:
SwDrawDev(OutputDevice * pOutDev,const Point * pPosition)45 	inline SwDrawDev( OutputDevice *pOutDev, const Point *pPosition )
46 		:pOut(pOutDev), pPos(pPosition) { }
47 
GetOut()48 	inline OutputDevice *GetOut() { return pOut; }
49 
50 	// Ausgabemethoden
51 	inline void DrawText( const Point& rStart, const String& rTxt,
52 						  const sal_uInt16 nIdx = 0,
53 						  const sal_uInt16 nLen = STRING_LEN );
54 	inline void DrawStretchText( const Point& rStart, sal_uInt16 nWidth,
55 						  const String& rTxt,
56 						  const sal_uInt16 nIdx = 0,
57 						  const sal_uInt16 nLen = STRING_LEN );
58 	inline void DrawTextArray( const Point& rStart,
59 						  const String& rTxt,
60 						  long *pKernArray = 0,
61 						  const sal_uInt16 nIdx = 0,
62 						  const sal_uInt16 nLen = STRING_LEN);
63 	inline void DrawLine( const Point& rStart, const Point& rEnd );
64 	inline void DrawRect( const SwRect& rRect,
65 						  const sal_uInt16 nHorzRount = 0,
66 						  const sal_uInt16 nVertRound = 0 );
67 
GetOrigin() const68 	inline const Point *GetOrigin() const {return pPos; }
69 };
70 
71 /*************************************************************************
72  *						SwDrawDev::DrawText
73  *************************************************************************/
74 
DrawText(const Point & rStart,const String & rTxt,const sal_uInt16 nIdx,const sal_uInt16 nLen)75 inline void SwDrawDev::DrawText( const Point& rStart, const String& rTxt,
76 								 const sal_uInt16 nIdx, const sal_uInt16 nLen )
77 {
78 	if( !pPos )
79 		pOut->DrawText( rStart, rTxt, nIdx, nLen );
80 	else
81 		pOut->DrawText( rStart - *pPos, rTxt, nIdx, nLen );
82 }
83 
84 /*************************************************************************
85  *						SwDrawDev::DrawStretchText
86  *************************************************************************/
87 
DrawStretchText(const Point & rStart,sal_uInt16 nWidth,const String & rTxt,const sal_uInt16 nIdx,const sal_uInt16 nLen)88 inline void SwDrawDev::DrawStretchText( const Point& rStart, sal_uInt16 nWidth,
89 	   const String& rTxt, const sal_uInt16 nIdx, const sal_uInt16 nLen )
90 {
91 	if( !pPos )
92 		pOut->DrawStretchText( rStart, nWidth, rTxt, nIdx, nLen );
93 	else
94 		pOut->DrawStretchText( rStart - *pPos, nWidth, rTxt, nIdx, nLen );
95 }
96 
97 /*************************************************************************
98  *						SwDrawDev::DrawTextArray
99  *************************************************************************/
100 
DrawTextArray(const Point & rStart,const String & rTxt,long * pKernArray,const sal_uInt16 nIdx,const sal_uInt16 nLen)101 inline void SwDrawDev::DrawTextArray( const Point& rStart, const String& rTxt,
102 			long *pKernArray, const sal_uInt16 nIdx, const sal_uInt16 nLen )
103 {
104 	if( !pPos )
105 		pOut->DrawTextArray( rStart, rTxt, pKernArray, nIdx, nLen );
106 	else
107 		pOut->DrawTextArray( rStart - *pPos, rTxt, pKernArray, nIdx, nLen );
108 }
109 
110 /*************************************************************************
111  *						SwDrawDev::DrawLine
112  *************************************************************************/
113 
DrawLine(const Point & rStart,const Point & rEnd)114 inline void SwDrawDev::DrawLine( const Point& rStart, const Point& rEnd )
115 {
116 	if( !pPos )
117 		pOut->DrawLine( rStart, rEnd );
118 	else
119 		pOut->DrawLine( rStart - *pPos, rEnd - *pPos );
120 }
121 
122 /*************************************************************************
123  *						SwDrawDev::DrawRect
124  *************************************************************************/
125 
DrawRect(const SwRect & rRect,const sal_uInt16 nHorzRound,const sal_uInt16 nVertRound)126 inline void SwDrawDev::DrawRect( const SwRect& rRect,
127 					  const sal_uInt16 nHorzRound, const sal_uInt16 nVertRound )
128 {
129 	SwRect aRect( rRect );
130 	if( pPos )
131 		aRect.Pos() -= *pPos;
132 	pOut->DrawRect( aRect.SVRect(), nHorzRound, nVertRound );
133 }
134 
135 
136 #endif
137