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 .
22 #include <vcl/gdimtf.hxx>
23 #include <vcl/metaact.hxx>
24 #include <vcl/outdev.hxx>
25 #include <vcl/virdev.hxx>
29 void OutputDevice::DrawEllipse( const tools::Rectangle
& rRect
)
31 assert(!is_double_buffered_window());
34 mpMetaFile
->AddAction( new MetaEllipseAction( rRect
) );
36 if ( !IsDeviceOutputNecessary() || (!mbLineColor
&& !mbFillColor
) || ImplIsRecordLayout() )
39 tools::Rectangle
aRect( ImplLogicToDevicePixel( rRect
) );
40 if ( aRect
.IsEmpty() )
44 if ( !mpGraphics
&& !AcquireGraphics() )
47 if ( mbInitClipRegion
)
49 if ( mbOutputClipped
)
52 if ( mbInitLineColor
)
55 tools::Polygon
aRectPoly( aRect
.Center(), aRect
.GetWidth() >> 1, aRect
.GetHeight() >> 1 );
56 if ( aRectPoly
.GetSize() >= 2 )
58 SalPoint
* pPtAry
= reinterpret_cast<SalPoint
*>(aRectPoly
.GetPointAry());
60 mpGraphics
->DrawPolyLine( aRectPoly
.GetSize(), pPtAry
, this );
63 if ( mbInitFillColor
)
65 mpGraphics
->DrawPolygon( aRectPoly
.GetSize(), pPtAry
, this );
70 mpAlphaVDev
->DrawEllipse( rRect
);
73 void OutputDevice::DrawArc( const tools::Rectangle
& rRect
,
74 const Point
& rStartPt
, const Point
& rEndPt
)
76 assert(!is_double_buffered_window());
79 mpMetaFile
->AddAction( new MetaArcAction( rRect
, rStartPt
, rEndPt
) );
81 if ( !IsDeviceOutputNecessary() || !mbLineColor
|| ImplIsRecordLayout() )
84 tools::Rectangle
aRect( ImplLogicToDevicePixel( rRect
) );
85 if ( aRect
.IsEmpty() )
89 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 SalPoint
* pPtAry
= reinterpret_cast<SalPoint
*>(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() )
133 if ( mbInitClipRegion
)
135 if ( mbOutputClipped
)
138 if ( mbInitLineColor
)
141 const Point
aStart( ImplLogicToDevicePixel( rStartPt
) );
142 const Point
aEnd( ImplLogicToDevicePixel( rEndPt
) );
143 tools::Polygon
aPiePoly( aRect
, aStart
, aEnd
, PolyStyle::Pie
);
145 if ( aPiePoly
.GetSize() >= 2 )
147 SalPoint
* pPtAry
= reinterpret_cast<SalPoint
*>(aPiePoly
.GetPointAry());
149 mpGraphics
->DrawPolyLine( aPiePoly
.GetSize(), pPtAry
, this );
152 if ( mbInitFillColor
)
154 mpGraphics
->DrawPolygon( aPiePoly
.GetSize(), pPtAry
, this );
159 mpAlphaVDev
->DrawPie( rRect
, rStartPt
, rEndPt
);
162 void OutputDevice::DrawChord( const tools::Rectangle
& rRect
,
163 const Point
& rStartPt
, const Point
& rEndPt
)
165 assert(!is_double_buffered_window());
168 mpMetaFile
->AddAction( new MetaChordAction( rRect
, rStartPt
, rEndPt
) );
170 if ( !IsDeviceOutputNecessary() || (!mbLineColor
&& !mbFillColor
) || ImplIsRecordLayout() )
173 tools::Rectangle
aRect( ImplLogicToDevicePixel( rRect
) );
174 if ( aRect
.IsEmpty() )
177 // we need a graphics
178 if ( !mpGraphics
&& !AcquireGraphics() )
181 if ( mbInitClipRegion
)
183 if ( mbOutputClipped
)
186 if ( mbInitLineColor
)
189 const Point
aStart( ImplLogicToDevicePixel( rStartPt
) );
190 const Point
aEnd( ImplLogicToDevicePixel( rEndPt
) );
191 tools::Polygon
aChordPoly( aRect
, aStart
, aEnd
, PolyStyle::Chord
);
193 if ( aChordPoly
.GetSize() >= 2 )
195 SalPoint
* pPtAry
= reinterpret_cast<SalPoint
*>(aChordPoly
.GetPointAry());
197 mpGraphics
->DrawPolyLine( aChordPoly
.GetSize(), pPtAry
, this );
200 if ( mbInitFillColor
)
202 mpGraphics
->DrawPolygon( aChordPoly
.GetSize(), pPtAry
, this );
207 mpAlphaVDev
->DrawChord( rRect
, rStartPt
, rEndPt
);
210 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */