1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <vcl/metaact.hxx>
21 #include <vcl/virdev.hxx>
27 void OutputDevice::DrawEllipse( const tools::Rectangle
& rRect
)
29 assert(!is_double_buffered_window());
32 mpMetaFile
->AddAction( new MetaEllipseAction( rRect
) );
34 if ( !IsDeviceOutputNecessary() || (!mbLineColor
&& !mbFillColor
) || ImplIsRecordLayout() )
37 tools::Rectangle
aRect( ImplLogicToDevicePixel( rRect
) );
38 if ( aRect
.IsEmpty() )
42 if ( !mpGraphics
&& !AcquireGraphics() )
46 if ( mbInitClipRegion
)
48 if ( mbOutputClipped
)
51 if ( mbInitLineColor
)
54 tools::Polygon
aRectPoly( aRect
.Center(), aRect
.GetWidth() >> 1, aRect
.GetHeight() >> 1 );
55 if ( aRectPoly
.GetSize() >= 2 )
57 Point
* pPtAry
= aRectPoly
.GetPointAry();
59 mpGraphics
->DrawPolyLine( aRectPoly
.GetSize(), pPtAry
, *this );
62 if ( mbInitFillColor
)
64 mpGraphics
->DrawPolygon( aRectPoly
.GetSize(), pPtAry
, *this );
69 mpAlphaVDev
->DrawEllipse( rRect
);
72 void OutputDevice::DrawArc( const tools::Rectangle
& rRect
,
73 const Point
& rStartPt
, const Point
& rEndPt
)
75 assert(!is_double_buffered_window());
78 mpMetaFile
->AddAction( new MetaArcAction( rRect
, rStartPt
, rEndPt
) );
80 if ( !IsDeviceOutputNecessary() || !mbLineColor
|| ImplIsRecordLayout() )
83 tools::Rectangle
aRect( ImplLogicToDevicePixel( rRect
) );
84 if ( aRect
.IsEmpty() )
88 if ( !mpGraphics
&& !AcquireGraphics() )
92 if ( mbInitClipRegion
)
94 if ( mbOutputClipped
)
97 if ( mbInitLineColor
)
100 const Point
aStart( ImplLogicToDevicePixel( rStartPt
) );
101 const Point
aEnd( ImplLogicToDevicePixel( rEndPt
) );
102 tools::Polygon
aArcPoly( aRect
, aStart
, aEnd
, PolyStyle::Arc
);
104 if ( aArcPoly
.GetSize() >= 2 )
106 Point
* pPtAry
= aArcPoly
.GetPointAry();
107 mpGraphics
->DrawPolyLine( aArcPoly
.GetSize(), pPtAry
, *this );
111 mpAlphaVDev
->DrawArc( rRect
, rStartPt
, rEndPt
);
114 void OutputDevice::DrawPie( const tools::Rectangle
& rRect
,
115 const Point
& rStartPt
, const Point
& rEndPt
)
117 assert(!is_double_buffered_window());
120 mpMetaFile
->AddAction( new MetaPieAction( rRect
, rStartPt
, rEndPt
) );
122 if ( !IsDeviceOutputNecessary() || (!mbLineColor
&& !mbFillColor
) || ImplIsRecordLayout() )
125 tools::Rectangle
aRect( ImplLogicToDevicePixel( rRect
) );
126 if ( aRect
.IsEmpty() )
129 // we need a graphics
130 if ( !mpGraphics
&& !AcquireGraphics() )
134 if ( mbInitClipRegion
)
136 if ( mbOutputClipped
)
139 if ( mbInitLineColor
)
142 const Point
aStart( ImplLogicToDevicePixel( rStartPt
) );
143 const Point
aEnd( ImplLogicToDevicePixel( rEndPt
) );
144 tools::Polygon
aPiePoly( aRect
, aStart
, aEnd
, PolyStyle::Pie
);
146 if ( aPiePoly
.GetSize() >= 2 )
148 Point
* pPtAry
= aPiePoly
.GetPointAry();
150 mpGraphics
->DrawPolyLine( aPiePoly
.GetSize(), pPtAry
, *this );
153 if ( mbInitFillColor
)
155 mpGraphics
->DrawPolygon( aPiePoly
.GetSize(), pPtAry
, *this );
160 mpAlphaVDev
->DrawPie( rRect
, rStartPt
, rEndPt
);
163 void OutputDevice::DrawChord( const tools::Rectangle
& rRect
,
164 const Point
& rStartPt
, const Point
& rEndPt
)
166 assert(!is_double_buffered_window());
169 mpMetaFile
->AddAction( new MetaChordAction( rRect
, rStartPt
, rEndPt
) );
171 if ( !IsDeviceOutputNecessary() || (!mbLineColor
&& !mbFillColor
) || ImplIsRecordLayout() )
174 tools::Rectangle
aRect( ImplLogicToDevicePixel( rRect
) );
175 if ( aRect
.IsEmpty() )
178 // we need a graphics
179 if ( !mpGraphics
&& !AcquireGraphics() )
183 if ( mbInitClipRegion
)
185 if ( mbOutputClipped
)
188 if ( mbInitLineColor
)
191 const Point
aStart( ImplLogicToDevicePixel( rStartPt
) );
192 const Point
aEnd( ImplLogicToDevicePixel( rEndPt
) );
193 tools::Polygon
aChordPoly( aRect
, aStart
, aEnd
, PolyStyle::Chord
);
195 if ( aChordPoly
.GetSize() >= 2 )
197 Point
* pPtAry
= aChordPoly
.GetPointAry();
199 mpGraphics
->DrawPolyLine( aChordPoly
.GetSize(), pPtAry
, *this );
202 if ( mbInitFillColor
)
204 mpGraphics
->DrawPolygon( aChordPoly
.GetSize(), pPtAry
, *this );
209 mpAlphaVDev
->DrawChord( rRect
, rStartPt
, rEndPt
);
212 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */