LibreOffice Module vcl (master) 1
curvedshapes.cxx
Go to the documentation of this file.
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#include <vcl/metaact.hxx>
21#include <vcl/virdev.hxx>
22
23#include <salgdi.hxx>
24
25#include <cassert>
26
28{
30
31 if ( mpMetaFile )
32 mpMetaFile->AddAction( new MetaEllipseAction( rRect ) );
33
35 return;
36
38 if ( aRect.IsEmpty() )
39 return;
40
41 // we need a graphics
42 if ( !mpGraphics && !AcquireGraphics() )
43 return;
44 assert(mpGraphics);
45
46 if ( mbInitClipRegion )
48 if ( mbOutputClipped )
49 return;
50
51 if ( mbInitLineColor )
53
54 tools::Polygon aRectPoly( aRect.Center(), aRect.GetWidth() >> 1, aRect.GetHeight() >> 1 );
55 if ( aRectPoly.GetSize() >= 2 )
56 {
57 Point* pPtAry = aRectPoly.GetPointAry();
58 if ( !mbFillColor )
59 mpGraphics->DrawPolyLine( aRectPoly.GetSize(), pPtAry, *this );
60 else
61 {
62 if ( mbInitFillColor )
64 mpGraphics->DrawPolygon( aRectPoly.GetSize(), pPtAry, *this );
65 }
66 }
67
68 if( mpAlphaVDev )
69 mpAlphaVDev->DrawEllipse( rRect );
70}
71
73 const Point& rStartPt, const Point& rEndPt )
74{
76
77 if ( mpMetaFile )
78 mpMetaFile->AddAction( new MetaArcAction( rRect, rStartPt, rEndPt ) );
79
81 return;
82
84 if ( aRect.IsEmpty() )
85 return;
86
87 // we need a graphics
88 if ( !mpGraphics && !AcquireGraphics() )
89 return;
90 assert(mpGraphics);
91
92 if ( mbInitClipRegion )
94 if ( mbOutputClipped )
95 return;
96
97 if ( mbInitLineColor )
99
100 const Point aStart( ImplLogicToDevicePixel( rStartPt ) );
101 const Point aEnd( ImplLogicToDevicePixel( rEndPt ) );
102 tools::Polygon aArcPoly( aRect, aStart, aEnd, PolyStyle::Arc );
103
104 if ( aArcPoly.GetSize() >= 2 )
105 {
106 Point* pPtAry = aArcPoly.GetPointAry();
107 mpGraphics->DrawPolyLine( aArcPoly.GetSize(), pPtAry, *this );
108 }
109
110 if( mpAlphaVDev )
111 mpAlphaVDev->DrawArc( rRect, rStartPt, rEndPt );
112}
113
115 const Point& rStartPt, const Point& rEndPt )
116{
117 assert(!is_double_buffered_window());
118
119 if ( mpMetaFile )
120 mpMetaFile->AddAction( new MetaPieAction( rRect, rStartPt, rEndPt ) );
121
123 return;
124
126 if ( aRect.IsEmpty() )
127 return;
128
129 // we need a graphics
130 if ( !mpGraphics && !AcquireGraphics() )
131 return;
132 assert(mpGraphics);
133
134 if ( mbInitClipRegion )
136 if ( mbOutputClipped )
137 return;
138
139 if ( mbInitLineColor )
141
142 const Point aStart( ImplLogicToDevicePixel( rStartPt ) );
143 const Point aEnd( ImplLogicToDevicePixel( rEndPt ) );
144 tools::Polygon aPiePoly( aRect, aStart, aEnd, PolyStyle::Pie );
145
146 if ( aPiePoly.GetSize() >= 2 )
147 {
148 Point* pPtAry = aPiePoly.GetPointAry();
149 if ( !mbFillColor )
150 mpGraphics->DrawPolyLine( aPiePoly.GetSize(), pPtAry, *this );
151 else
152 {
153 if ( mbInitFillColor )
155 mpGraphics->DrawPolygon( aPiePoly.GetSize(), pPtAry, *this );
156 }
157 }
158
159 if( mpAlphaVDev )
160 mpAlphaVDev->DrawPie( rRect, rStartPt, rEndPt );
161}
162
164 const Point& rStartPt, const Point& rEndPt )
165{
166 assert(!is_double_buffered_window());
167
168 if ( mpMetaFile )
169 mpMetaFile->AddAction( new MetaChordAction( rRect, rStartPt, rEndPt ) );
170
172 return;
173
175 if ( aRect.IsEmpty() )
176 return;
177
178 // we need a graphics
179 if ( !mpGraphics && !AcquireGraphics() )
180 return;
181 assert(mpGraphics);
182
183 if ( mbInitClipRegion )
185 if ( mbOutputClipped )
186 return;
187
188 if ( mbInitLineColor )
190
191 const Point aStart( ImplLogicToDevicePixel( rStartPt ) );
192 const Point aEnd( ImplLogicToDevicePixel( rEndPt ) );
193 tools::Polygon aChordPoly( aRect, aStart, aEnd, PolyStyle::Chord );
194
195 if ( aChordPoly.GetSize() >= 2 )
196 {
197 Point* pPtAry = aChordPoly.GetPointAry();
198 if ( !mbFillColor )
199 mpGraphics->DrawPolyLine( aChordPoly.GetSize(), pPtAry, *this );
200 else
201 {
202 if ( mbInitFillColor )
204 mpGraphics->DrawPolygon( aChordPoly.GetSize(), pPtAry, *this );
205 }
206 }
207
208 if( mpAlphaVDev )
209 mpAlphaVDev->DrawChord( rRect, rStartPt, rEndPt );
210}
211
212/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void AddAction(const rtl::Reference< MetaAction > &pAction)
Definition: gdimtf.cxx:585
virtual void InitClipRegion()
SAL_DLLPRIVATE bool is_double_buffered_window() const
SAL_DLLPRIVATE void InitLineColor()
Definition: line.cxx:85
bool mbOutputClipped
Definition: outdev.hxx:245
void DrawEllipse(const tools::Rectangle &rRect)
SAL_DLLPRIVATE tools::Rectangle ImplLogicToDevicePixel(const tools::Rectangle &rLogicRect) const
Convert a logical rectangle to a rectangle in physical device pixel units.
Definition: map.cxx:334
bool mbFillColor
Definition: outdev.hxx:247
virtual bool AcquireGraphics() const =0
Acquire a graphics device that the output device uses to draw on.
SAL_DLLPRIVATE bool ImplIsRecordLayout() const
Definition: outdev.cxx:708
GDIMetaFile * mpMetaFile
Definition: outdev.hxx:185
SAL_DLLPRIVATE void InitFillColor()
Definition: fill.cxx:76
bool mbInitLineColor
Definition: outdev.hxx:248
SalGraphics * mpGraphics
Graphics context to draw on.
Definition: outdev.hxx:182
bool mbInitClipRegion
Definition: outdev.hxx:252
void DrawChord(const tools::Rectangle &rRect, const Point &rStartPt, const Point &rEndPt)
bool IsDeviceOutputNecessary() const
Definition: outdev.hxx:481
VclPtr< VirtualDevice > mpAlphaVDev
Definition: outdev.hxx:196
void DrawArc(const tools::Rectangle &rRect, const Point &rStartPt, const Point &rEndPt)
void DrawPie(const tools::Rectangle &rRect, const Point &rStartPt, const Point &rEndPt)
bool mbLineColor
Definition: outdev.hxx:246
bool mbInitFillColor
Definition: outdev.hxx:249
void DrawPolyLine(sal_uInt32 nPoints, Point const *pPtAry, const OutputDevice &rOutDev)
void DrawPolygon(sal_uInt32 nPoints, const Point *pPtAry, const OutputDevice &rOutDev)
sal_uInt16 GetSize() const
Point * GetPointAry()
constexpr Point Center() const
constexpr tools::Long GetWidth() const
constexpr tools::Long GetHeight() const
constexpr bool IsEmpty() const