xref: /aoo41x/main/vcl/source/gdi/outdev5.cxx (revision 9f62ea84)
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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_vcl.hxx"
26 
27 #include <tools/ref.hxx>
28 #include <tools/debug.hxx>
29 #include <tools/poly.hxx>
30 
31 #include <vcl/metaact.hxx>
32 #include <vcl/gdimtf.hxx>
33 #include <vcl/outdev.hxx>
34 #include <vcl/virdev.hxx>
35 
36 #include <salgdi.hxx>
37 #include <svdata.hxx>
38 #include <outdata.hxx>
39 #include <outdev.h>
40 
41 // =======================================================================
42 
DBG_NAMEEX(OutputDevice)43 DBG_NAMEEX( OutputDevice )
44 
45 // =======================================================================
46 
47 void OutputDevice::DrawRect( const Rectangle& rRect,
48 							 sal_uLong nHorzRound, sal_uLong nVertRound )
49 {
50 	DBG_TRACE( "OutputDevice::DrawRoundRect()" );
51 	DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
52 
53 	if ( mpMetaFile )
54 		mpMetaFile->AddAction( new MetaRoundRectAction( rRect, nHorzRound, nVertRound ) );
55 
56 	if ( !IsDeviceOutputNecessary() || (!mbLineColor && !mbFillColor) || ImplIsRecordLayout() )
57 		return;
58 
59 	const Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
60 
61 	if ( aRect.IsEmpty() )
62 		return;
63 
64 	nHorzRound = ImplLogicWidthToDevicePixel( nHorzRound );
65 	nVertRound = ImplLogicHeightToDevicePixel( nVertRound );
66 
67 	// we need a graphics
68 	if ( !mpGraphics )
69 	{
70 		if ( !ImplGetGraphics() )
71 			return;
72 	}
73 
74 	if ( mbInitClipRegion )
75 		ImplInitClipRegion();
76 	if ( mbOutputClipped )
77 		return;
78 
79 	if ( mbInitLineColor )
80 		ImplInitLineColor();
81 	if ( mbInitFillColor )
82 		ImplInitFillColor();
83 
84 	if ( !nHorzRound && !nVertRound )
85 		mpGraphics->DrawRect( aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight(), this );
86 	else
87 	{
88 		const Polygon aRoundRectPoly( aRect, nHorzRound, nVertRound );
89 
90 		if ( aRoundRectPoly.GetSize() >= 2 )
91 		{
92 			const SalPoint* pPtAry = (const SalPoint*) aRoundRectPoly.GetConstPointAry();
93 
94 			if ( !mbFillColor )
95 				mpGraphics->DrawPolyLine( aRoundRectPoly.GetSize(), pPtAry, this );
96 			else
97 				mpGraphics->DrawPolygon( aRoundRectPoly.GetSize(), pPtAry, this );
98 		}
99 	}
100 
101     if( mpAlphaVDev )
102         mpAlphaVDev->DrawRect( rRect, nHorzRound, nVertRound );
103 }
104 
105 // -----------------------------------------------------------------------
106 
DrawEllipse(const Rectangle & rRect)107 void OutputDevice::DrawEllipse( const Rectangle& rRect )
108 {
109 	DBG_TRACE( "OutputDevice::DrawEllipse()" );
110 	DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
111 
112 	if ( mpMetaFile )
113 		mpMetaFile->AddAction( new MetaEllipseAction( rRect ) );
114 
115 	if	( !IsDeviceOutputNecessary() || (!mbLineColor && !mbFillColor) || ImplIsRecordLayout() )
116 		return;
117 
118 	Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
119 	if ( aRect.IsEmpty() )
120 		return;
121 
122 	// we need a graphics
123 	if ( !mpGraphics )
124 	{
125 		if ( !ImplGetGraphics() )
126 			return;
127 	}
128 
129 	if ( mbInitClipRegion )
130 		ImplInitClipRegion();
131 	if ( mbOutputClipped )
132 		return;
133 
134 	if ( mbInitLineColor )
135 		ImplInitLineColor();
136 
137 	Polygon aRectPoly( aRect.Center(), aRect.GetWidth() >> 1, aRect.GetHeight() >> 1 );
138 	if ( aRectPoly.GetSize() >= 2 )
139 	{
140 		const SalPoint* pPtAry = (const SalPoint*)aRectPoly.GetConstPointAry();
141 		if ( !mbFillColor )
142 			mpGraphics->DrawPolyLine( aRectPoly.GetSize(), pPtAry, this );
143 		else
144 		{
145 			if ( mbInitFillColor )
146 				ImplInitFillColor();
147 			mpGraphics->DrawPolygon( aRectPoly.GetSize(), pPtAry, this );
148 		}
149 	}
150 
151     if( mpAlphaVDev )
152         mpAlphaVDev->DrawEllipse( rRect );
153 }
154 
155 // -----------------------------------------------------------------------
156 
DrawArc(const Rectangle & rRect,const Point & rStartPt,const Point & rEndPt)157 void OutputDevice::DrawArc( const Rectangle& rRect,
158 							const Point& rStartPt, const Point& rEndPt )
159 {
160 	DBG_TRACE( "OutputDevice::DrawArc()" );
161 	DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
162 
163 	if ( mpMetaFile )
164 		mpMetaFile->AddAction( new MetaArcAction( rRect, rStartPt, rEndPt ) );
165 
166 	if ( !IsDeviceOutputNecessary() || !mbLineColor || ImplIsRecordLayout() )
167 		return;
168 
169 	Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
170 	if ( aRect.IsEmpty() )
171 		return;
172 
173 	// we need a graphics
174 	if ( !mpGraphics )
175 	{
176 		if ( !ImplGetGraphics() )
177 			return;
178 	}
179 
180 	if ( mbInitClipRegion )
181 		ImplInitClipRegion();
182 	if ( mbOutputClipped )
183 		return;
184 
185 	if ( mbInitLineColor )
186 		ImplInitLineColor();
187 
188 	const Point 	aStart( ImplLogicToDevicePixel( rStartPt ) );
189 	const Point 	aEnd( ImplLogicToDevicePixel( rEndPt ) );
190 	Polygon 		aArcPoly( aRect, aStart, aEnd, POLY_ARC );
191 
192 	if ( aArcPoly.GetSize() >= 2 )
193 	{
194 		const SalPoint* pPtAry = (const SalPoint*)aArcPoly.GetConstPointAry();
195 		mpGraphics->DrawPolyLine( aArcPoly.GetSize(), pPtAry, this );
196 	}
197 
198     if( mpAlphaVDev )
199         mpAlphaVDev->DrawArc( rRect, rStartPt, rEndPt );
200 }
201 
202 // -----------------------------------------------------------------------
203 
DrawPie(const Rectangle & rRect,const Point & rStartPt,const Point & rEndPt)204 void OutputDevice::DrawPie( const Rectangle& rRect,
205 							const Point& rStartPt, const Point& rEndPt )
206 {
207 	DBG_TRACE( "OutputDevice::DrawPie()" );
208 	DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
209 
210 	if ( mpMetaFile )
211 		mpMetaFile->AddAction( new MetaPieAction( rRect, rStartPt, rEndPt ) );
212 
213 	if ( !IsDeviceOutputNecessary() || (!mbLineColor && !mbFillColor) || ImplIsRecordLayout() )
214 		return;
215 
216 	Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
217 	if ( aRect.IsEmpty() )
218 		return;
219 
220 	// we need a graphics
221 	if ( !mpGraphics )
222 	{
223 		if ( !ImplGetGraphics() )
224 			return;
225 	}
226 
227 	if ( mbInitClipRegion )
228 		ImplInitClipRegion();
229 	if ( mbOutputClipped )
230 		return;
231 
232 	if ( mbInitLineColor )
233 		ImplInitLineColor();
234 
235 	const Point 	aStart( ImplLogicToDevicePixel( rStartPt ) );
236 	const Point 	aEnd( ImplLogicToDevicePixel( rEndPt ) );
237 	Polygon 		aPiePoly( aRect, aStart, aEnd, POLY_PIE );
238 
239 	if ( aPiePoly.GetSize() >= 2 )
240 	{
241 		const SalPoint* pPtAry = (const SalPoint*)aPiePoly.GetConstPointAry();
242 		if ( !mbFillColor )
243 			mpGraphics->DrawPolyLine( aPiePoly.GetSize(), pPtAry, this );
244 		else
245 		{
246 			if ( mbInitFillColor )
247 				ImplInitFillColor();
248 			mpGraphics->DrawPolygon( aPiePoly.GetSize(), pPtAry, this );
249 		}
250 	}
251 
252     if( mpAlphaVDev )
253         mpAlphaVDev->DrawPie( rRect, rStartPt, rEndPt );
254 }
255 
256 // -----------------------------------------------------------------------
257 
DrawChord(const Rectangle & rRect,const Point & rStartPt,const Point & rEndPt)258 void OutputDevice::DrawChord( const Rectangle& rRect,
259 							  const Point& rStartPt, const Point& rEndPt )
260 {
261 	DBG_TRACE( "OutputDevice::DrawChord()" );
262 	DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
263 
264 	if ( mpMetaFile )
265 		mpMetaFile->AddAction( new MetaChordAction( rRect, rStartPt, rEndPt ) );
266 
267 	if ( !IsDeviceOutputNecessary() || (!mbLineColor && !mbFillColor) || ImplIsRecordLayout() )
268 		return;
269 
270 	Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
271 	if ( aRect.IsEmpty() )
272 		return;
273 
274 	// we need a graphics
275 	if ( !mpGraphics )
276 	{
277 		if ( !ImplGetGraphics() )
278 			return;
279 	}
280 
281 	if ( mbInitClipRegion )
282 		ImplInitClipRegion();
283 	if ( mbOutputClipped )
284 		return;
285 
286 	if ( mbInitLineColor )
287 		ImplInitLineColor();
288 
289 	const Point 	aStart( ImplLogicToDevicePixel( rStartPt ) );
290 	const Point 	aEnd( ImplLogicToDevicePixel( rEndPt ) );
291 	Polygon 		aChordPoly( aRect, aStart, aEnd, POLY_CHORD );
292 
293 	if ( aChordPoly.GetSize() >= 2 )
294 	{
295 		const SalPoint* pPtAry = (const SalPoint*)aChordPoly.GetConstPointAry();
296 		if ( !mbFillColor )
297 			mpGraphics->DrawPolyLine( aChordPoly.GetSize(), pPtAry, this );
298 		else
299 		{
300 			if ( mbInitFillColor )
301 				ImplInitFillColor();
302 			mpGraphics->DrawPolygon( aChordPoly.GetSize(), pPtAry, this );
303 		}
304 	}
305 
306     if( mpAlphaVDev )
307         mpAlphaVDev->DrawChord( rRect, rStartPt, rEndPt );
308 }
309