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 <cassert>
21
22#include <vcl/gdimtf.hxx>
23#include <vcl/metaact.hxx>
24#include <vcl/outdev.hxx>
25#include <vcl/virdev.hxx>
26
27#include <salgdi.hxx>
28
30{
32
33 if ( mpMetaFile )
34 mpMetaFile->AddAction( new MetaEllipseAction( rRect ) );
35
37 return;
38
40 if ( aRect.IsEmpty() )
41 return;
42
43 // we need a graphics
44 if ( !mpGraphics && !AcquireGraphics() )
45 return;
46 assert(mpGraphics);
47
48 if ( mbInitClipRegion )
50 if ( mbOutputClipped )
51 return;
52
53 if ( mbInitLineColor )
55
56 tools::Polygon aRectPoly( aRect.Center(), aRect.GetWidth() >> 1, aRect.GetHeight() >> 1 );
57 if ( aRectPoly.GetSize() >= 2 )
58 {
59 Point* pPtAry = aRectPoly.GetPointAry();
60 if ( !mbFillColor )
61 mpGraphics->DrawPolyLine( aRectPoly.GetSize(), pPtAry, *this );
62 else
63 {
64 if ( mbInitFillColor )
66 mpGraphics->DrawPolygon( aRectPoly.GetSize(), pPtAry, *this );
67 }
68 }
69
70 if( mpAlphaVDev )
71 mpAlphaVDev->DrawEllipse( rRect );
72}
73
75 const Point& rStartPt, const Point& rEndPt )
76{
78
79 if ( mpMetaFile )
80 mpMetaFile->AddAction( new MetaArcAction( rRect, rStartPt, rEndPt ) );
81
83 return;
84
86 if ( aRect.IsEmpty() )
87 return;
88
89 // we need a graphics
90 if ( !mpGraphics && !AcquireGraphics() )
91 return;
92 assert(mpGraphics);
93
94 if ( mbInitClipRegion )
96 if ( mbOutputClipped )
97 return;
98
99 if ( mbInitLineColor )
101
102 const Point aStart( ImplLogicToDevicePixel( rStartPt ) );
103 const Point aEnd( ImplLogicToDevicePixel( rEndPt ) );
104 tools::Polygon aArcPoly( aRect, aStart, aEnd, PolyStyle::Arc );
105
106 if ( aArcPoly.GetSize() >= 2 )
107 {
108 Point* pPtAry = aArcPoly.GetPointAry();
109 mpGraphics->DrawPolyLine( aArcPoly.GetSize(), pPtAry, *this );
110 }
111
112 if( mpAlphaVDev )
113 mpAlphaVDev->DrawArc( rRect, rStartPt, rEndPt );
114}
115
117 const Point& rStartPt, const Point& rEndPt )
118{
119 assert(!is_double_buffered_window());
120
121 if ( mpMetaFile )
122 mpMetaFile->AddAction( new MetaPieAction( rRect, rStartPt, rEndPt ) );
123
125 return;
126
128 if ( aRect.IsEmpty() )
129 return;
130
131 // we need a graphics
132 if ( !mpGraphics && !AcquireGraphics() )
133 return;
134 assert(mpGraphics);
135
136 if ( mbInitClipRegion )
138 if ( mbOutputClipped )
139 return;
140
141 if ( mbInitLineColor )
143
144 const Point aStart( ImplLogicToDevicePixel( rStartPt ) );
145 const Point aEnd( ImplLogicToDevicePixel( rEndPt ) );
146 tools::Polygon aPiePoly( aRect, aStart, aEnd, PolyStyle::Pie );
147
148 if ( aPiePoly.GetSize() >= 2 )
149 {
150 Point* pPtAry = aPiePoly.GetPointAry();
151 if ( !mbFillColor )
152 mpGraphics->DrawPolyLine( aPiePoly.GetSize(), pPtAry, *this );
153 else
154 {
155 if ( mbInitFillColor )
157 mpGraphics->DrawPolygon( aPiePoly.GetSize(), pPtAry, *this );
158 }
159 }
160
161 if( mpAlphaVDev )
162 mpAlphaVDev->DrawPie( rRect, rStartPt, rEndPt );
163}
164
166 const Point& rStartPt, const Point& rEndPt )
167{
168 assert(!is_double_buffered_window());
169
170 if ( mpMetaFile )
171 mpMetaFile->AddAction( new MetaChordAction( rRect, rStartPt, rEndPt ) );
172
174 return;
175
177 if ( aRect.IsEmpty() )
178 return;
179
180 // we need a graphics
181 if ( !mpGraphics && !AcquireGraphics() )
182 return;
183 assert(mpGraphics);
184
185 if ( mbInitClipRegion )
187 if ( mbOutputClipped )
188 return;
189
190 if ( mbInitLineColor )
192
193 const Point aStart( ImplLogicToDevicePixel( rStartPt ) );
194 const Point aEnd( ImplLogicToDevicePixel( rEndPt ) );
195 tools::Polygon aChordPoly( aRect, aStart, aEnd, PolyStyle::Chord );
196
197 if ( aChordPoly.GetSize() >= 2 )
198 {
199 Point* pPtAry = aChordPoly.GetPointAry();
200 if ( !mbFillColor )
201 mpGraphics->DrawPolyLine( aChordPoly.GetSize(), pPtAry, *this );
202 else
203 {
204 if ( mbInitFillColor )
206 mpGraphics->DrawPolygon( aChordPoly.GetSize(), pPtAry, *this );
207 }
208 }
209
210 if( mpAlphaVDev )
211 mpAlphaVDev->DrawChord( rRect, rStartPt, rEndPt );
212}
213
214/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void AddAction(const rtl::Reference< MetaAction > &pAction)
Definition: gdimtf.cxx:581
virtual void InitClipRegion()
SAL_DLLPRIVATE bool is_double_buffered_window() const
SAL_DLLPRIVATE void InitLineColor()
Definition: line.cxx:84
bool mbOutputClipped
Definition: outdev.hxx:252
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:386
bool mbFillColor
Definition: outdev.hxx:254
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:724
GDIMetaFile * mpMetaFile
Definition: outdev.hxx:191
SAL_DLLPRIVATE void InitFillColor()
Definition: fill.cxx:76
bool mbInitLineColor
Definition: outdev.hxx:255
SalGraphics * mpGraphics
Graphics context to draw on.
Definition: outdev.hxx:188
bool mbInitClipRegion
Definition: outdev.hxx:259
void DrawChord(const tools::Rectangle &rRect, const Point &rStartPt, const Point &rEndPt)
bool IsDeviceOutputNecessary() const
Definition: outdev.hxx:488
VclPtr< VirtualDevice > mpAlphaVDev
Definition: outdev.hxx:202
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:253
bool mbInitFillColor
Definition: outdev.hxx:256
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