Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include <tools/debug.hxx>
22 : #include <tools/poly.hxx>
23 :
24 : #include <vcl/metaact.hxx>
25 : #include <vcl/gdimtf.hxx>
26 : #include <vcl/outdev.hxx>
27 : #include <vcl/virdev.hxx>
28 :
29 : #include <salgdi.hxx>
30 : #include <svdata.hxx>
31 : #include <outdata.hxx>
32 : #include <outdev.h>
33 :
34 : // =======================================================================
35 :
36 : DBG_NAMEEX( OutputDevice )
37 :
38 : // =======================================================================
39 :
40 0 : void OutputDevice::DrawRect( const Rectangle& rRect,
41 : sal_uLong nHorzRound, sal_uLong nVertRound )
42 : {
43 : DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
44 :
45 0 : if ( mpMetaFile )
46 0 : mpMetaFile->AddAction( new MetaRoundRectAction( rRect, nHorzRound, nVertRound ) );
47 :
48 0 : if ( !IsDeviceOutputNecessary() || (!mbLineColor && !mbFillColor) || ImplIsRecordLayout() )
49 0 : return;
50 :
51 0 : const Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
52 :
53 0 : if ( aRect.IsEmpty() )
54 0 : return;
55 :
56 0 : nHorzRound = ImplLogicWidthToDevicePixel( nHorzRound );
57 0 : nVertRound = ImplLogicHeightToDevicePixel( nVertRound );
58 :
59 : // we need a graphics
60 0 : if ( !mpGraphics )
61 : {
62 0 : if ( !ImplGetGraphics() )
63 0 : return;
64 : }
65 :
66 0 : if ( mbInitClipRegion )
67 0 : ImplInitClipRegion();
68 0 : if ( mbOutputClipped )
69 0 : return;
70 :
71 0 : if ( mbInitLineColor )
72 0 : ImplInitLineColor();
73 0 : if ( mbInitFillColor )
74 0 : ImplInitFillColor();
75 :
76 0 : if ( !nHorzRound && !nVertRound )
77 0 : mpGraphics->DrawRect( aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight(), this );
78 : else
79 : {
80 0 : const Polygon aRoundRectPoly( aRect, nHorzRound, nVertRound );
81 :
82 0 : if ( aRoundRectPoly.GetSize() >= 2 )
83 : {
84 0 : const SalPoint* pPtAry = (const SalPoint*) aRoundRectPoly.GetConstPointAry();
85 :
86 0 : if ( !mbFillColor )
87 0 : mpGraphics->DrawPolyLine( aRoundRectPoly.GetSize(), pPtAry, this );
88 : else
89 0 : mpGraphics->DrawPolygon( aRoundRectPoly.GetSize(), pPtAry, this );
90 0 : }
91 : }
92 :
93 0 : if( mpAlphaVDev )
94 0 : mpAlphaVDev->DrawRect( rRect, nHorzRound, nVertRound );
95 : }
96 :
97 : // -----------------------------------------------------------------------
98 :
99 1 : void OutputDevice::DrawEllipse( const Rectangle& rRect )
100 : {
101 : DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
102 :
103 1 : if ( mpMetaFile )
104 1 : mpMetaFile->AddAction( new MetaEllipseAction( rRect ) );
105 :
106 1 : if ( !IsDeviceOutputNecessary() || (!mbLineColor && !mbFillColor) || ImplIsRecordLayout() )
107 0 : return;
108 :
109 1 : Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
110 1 : if ( aRect.IsEmpty() )
111 0 : return;
112 :
113 : // we need a graphics
114 1 : if ( !mpGraphics )
115 : {
116 0 : if ( !ImplGetGraphics() )
117 0 : return;
118 : }
119 :
120 1 : if ( mbInitClipRegion )
121 0 : ImplInitClipRegion();
122 1 : if ( mbOutputClipped )
123 0 : return;
124 :
125 1 : if ( mbInitLineColor )
126 1 : ImplInitLineColor();
127 :
128 1 : Polygon aRectPoly( aRect.Center(), aRect.GetWidth() >> 1, aRect.GetHeight() >> 1 );
129 1 : if ( aRectPoly.GetSize() >= 2 )
130 : {
131 1 : const SalPoint* pPtAry = (const SalPoint*)aRectPoly.GetConstPointAry();
132 1 : if ( !mbFillColor )
133 0 : mpGraphics->DrawPolyLine( aRectPoly.GetSize(), pPtAry, this );
134 : else
135 : {
136 1 : if ( mbInitFillColor )
137 1 : ImplInitFillColor();
138 1 : mpGraphics->DrawPolygon( aRectPoly.GetSize(), pPtAry, this );
139 : }
140 : }
141 :
142 1 : if( mpAlphaVDev )
143 0 : mpAlphaVDev->DrawEllipse( rRect );
144 : }
145 :
146 : // -----------------------------------------------------------------------
147 :
148 0 : void OutputDevice::DrawArc( const Rectangle& rRect,
149 : const Point& rStartPt, const Point& rEndPt )
150 : {
151 : DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
152 :
153 0 : if ( mpMetaFile )
154 0 : mpMetaFile->AddAction( new MetaArcAction( rRect, rStartPt, rEndPt ) );
155 :
156 0 : if ( !IsDeviceOutputNecessary() || !mbLineColor || ImplIsRecordLayout() )
157 0 : return;
158 :
159 0 : Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
160 0 : if ( aRect.IsEmpty() )
161 0 : return;
162 :
163 : // we need a graphics
164 0 : if ( !mpGraphics )
165 : {
166 0 : if ( !ImplGetGraphics() )
167 0 : return;
168 : }
169 :
170 0 : if ( mbInitClipRegion )
171 0 : ImplInitClipRegion();
172 0 : if ( mbOutputClipped )
173 0 : return;
174 :
175 0 : if ( mbInitLineColor )
176 0 : ImplInitLineColor();
177 :
178 0 : const Point aStart( ImplLogicToDevicePixel( rStartPt ) );
179 0 : const Point aEnd( ImplLogicToDevicePixel( rEndPt ) );
180 0 : Polygon aArcPoly( aRect, aStart, aEnd, POLY_ARC );
181 :
182 0 : if ( aArcPoly.GetSize() >= 2 )
183 : {
184 0 : const SalPoint* pPtAry = (const SalPoint*)aArcPoly.GetConstPointAry();
185 0 : mpGraphics->DrawPolyLine( aArcPoly.GetSize(), pPtAry, this );
186 : }
187 :
188 0 : if( mpAlphaVDev )
189 0 : mpAlphaVDev->DrawArc( rRect, rStartPt, rEndPt );
190 : }
191 :
192 : // -----------------------------------------------------------------------
193 :
194 0 : void OutputDevice::DrawPie( const Rectangle& rRect,
195 : const Point& rStartPt, const Point& rEndPt )
196 : {
197 : DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
198 :
199 0 : if ( mpMetaFile )
200 0 : mpMetaFile->AddAction( new MetaPieAction( rRect, rStartPt, rEndPt ) );
201 :
202 0 : if ( !IsDeviceOutputNecessary() || (!mbLineColor && !mbFillColor) || ImplIsRecordLayout() )
203 0 : return;
204 :
205 0 : Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
206 0 : if ( aRect.IsEmpty() )
207 0 : return;
208 :
209 : // we need a graphics
210 0 : if ( !mpGraphics )
211 : {
212 0 : if ( !ImplGetGraphics() )
213 0 : return;
214 : }
215 :
216 0 : if ( mbInitClipRegion )
217 0 : ImplInitClipRegion();
218 0 : if ( mbOutputClipped )
219 0 : return;
220 :
221 0 : if ( mbInitLineColor )
222 0 : ImplInitLineColor();
223 :
224 0 : const Point aStart( ImplLogicToDevicePixel( rStartPt ) );
225 0 : const Point aEnd( ImplLogicToDevicePixel( rEndPt ) );
226 0 : Polygon aPiePoly( aRect, aStart, aEnd, POLY_PIE );
227 :
228 0 : if ( aPiePoly.GetSize() >= 2 )
229 : {
230 0 : const SalPoint* pPtAry = (const SalPoint*)aPiePoly.GetConstPointAry();
231 0 : if ( !mbFillColor )
232 0 : mpGraphics->DrawPolyLine( aPiePoly.GetSize(), pPtAry, this );
233 : else
234 : {
235 0 : if ( mbInitFillColor )
236 0 : ImplInitFillColor();
237 0 : mpGraphics->DrawPolygon( aPiePoly.GetSize(), pPtAry, this );
238 : }
239 : }
240 :
241 0 : if( mpAlphaVDev )
242 0 : mpAlphaVDev->DrawPie( rRect, rStartPt, rEndPt );
243 : }
244 :
245 : // -----------------------------------------------------------------------
246 :
247 0 : void OutputDevice::DrawChord( const Rectangle& rRect,
248 : const Point& rStartPt, const Point& rEndPt )
249 : {
250 : DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
251 :
252 0 : if ( mpMetaFile )
253 0 : mpMetaFile->AddAction( new MetaChordAction( rRect, rStartPt, rEndPt ) );
254 :
255 0 : if ( !IsDeviceOutputNecessary() || (!mbLineColor && !mbFillColor) || ImplIsRecordLayout() )
256 0 : return;
257 :
258 0 : Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
259 0 : if ( aRect.IsEmpty() )
260 0 : return;
261 :
262 : // we need a graphics
263 0 : if ( !mpGraphics )
264 : {
265 0 : if ( !ImplGetGraphics() )
266 0 : return;
267 : }
268 :
269 0 : if ( mbInitClipRegion )
270 0 : ImplInitClipRegion();
271 0 : if ( mbOutputClipped )
272 0 : return;
273 :
274 0 : if ( mbInitLineColor )
275 0 : ImplInitLineColor();
276 :
277 0 : const Point aStart( ImplLogicToDevicePixel( rStartPt ) );
278 0 : const Point aEnd( ImplLogicToDevicePixel( rEndPt ) );
279 0 : Polygon aChordPoly( aRect, aStart, aEnd, POLY_CHORD );
280 :
281 0 : if ( aChordPoly.GetSize() >= 2 )
282 : {
283 0 : const SalPoint* pPtAry = (const SalPoint*)aChordPoly.GetConstPointAry();
284 0 : if ( !mbFillColor )
285 0 : mpGraphics->DrawPolyLine( aChordPoly.GetSize(), pPtAry, this );
286 : else
287 : {
288 0 : if ( mbInitFillColor )
289 0 : ImplInitFillColor();
290 0 : mpGraphics->DrawPolygon( aChordPoly.GetSize(), pPtAry, this );
291 : }
292 : }
293 :
294 0 : if( mpAlphaVDev )
295 0 : mpAlphaVDev->DrawChord( rRect, rStartPt, rEndPt );
296 465 : }
297 :
298 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|