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 
39  tools::Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
40  if ( aRect.IsEmpty() )
41  return;
42 
43  // we need a graphics
44  if ( !mpGraphics && !AcquireGraphics() )
45  return;
47 
48  if ( mbInitClipRegion )
50  if ( mbOutputClipped )
51  return;
52 
53  if ( mbInitLineColor )
54  InitLineColor();
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 )
65  InitFillColor();
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 
85  tools::Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
86  if ( aRect.IsEmpty() )
87  return;
88 
89  // we need a graphics
90  if ( !mpGraphics && !AcquireGraphics() )
91  return;
93 
94  if ( mbInitClipRegion )
96  if ( mbOutputClipped )
97  return;
98 
99  if ( mbInitLineColor )
100  InitLineColor();
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 {
120 
121  if ( mpMetaFile )
122  mpMetaFile->AddAction( new MetaPieAction( rRect, rStartPt, rEndPt ) );
123 
125  return;
126 
127  tools::Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
128  if ( aRect.IsEmpty() )
129  return;
130 
131  // we need a graphics
132  if ( !mpGraphics && !AcquireGraphics() )
133  return;
135 
136  if ( mbInitClipRegion )
137  InitClipRegion();
138  if ( mbOutputClipped )
139  return;
140 
141  if ( mbInitLineColor )
142  InitLineColor();
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 )
156  InitFillColor();
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 {
169 
170  if ( mpMetaFile )
171  mpMetaFile->AddAction( new MetaChordAction( rRect, rStartPt, rEndPt ) );
172 
174  return;
175 
176  tools::Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
177  if ( aRect.IsEmpty() )
178  return;
179 
180  // we need a graphics
181  if ( !mpGraphics && !AcquireGraphics() )
182  return;
184 
185  if ( mbInitClipRegion )
186  InitClipRegion();
187  if ( mbOutputClipped )
188  return;
189 
190  if ( mbInitLineColor )
191  InitLineColor();
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 )
205  InitFillColor();
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: */
SAL_DLLPRIVATE bool ImplIsRecordLayout() const
Definition: outdev.cxx:644
bool mbOutputClipped
Definition: outdev.hxx:379
void DrawChord(const tools::Rectangle &rRect, const Point &rStartPt, const Point &rEndPt)
SAL_DLLPRIVATE bool is_double_buffered_window() const
tools::Long GetWidth() const
bool IsEmpty() const
SAL_DLLPRIVATE void InitLineColor()
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
SalGraphics * mpGraphics
Graphics context to draw on.
Definition: outdev.hxx:315
SAL_DLLPRIVATE void InitFillColor()
void DrawPolygon(sal_uInt32 nPoints, const Point *pPtAry, const OutputDevice &rOutDev)
Point * GetPointAry()
virtual bool AcquireGraphics() const =0
Acquire a graphics device that the output device uses to draw on.
void DrawArc(const tools::Rectangle &rRect, const Point &rStartPt, const Point &rEndPt)
bool mbInitLineColor
Definition: outdev.hxx:382
void DrawPolyLine(sal_uInt32 nPoints, Point const *pPtAry, const OutputDevice &rOutDev)
bool mbLineColor
Definition: outdev.hxx:380
sal_uInt16 GetSize() const
void DrawPie(const tools::Rectangle &rRect, const Point &rStartPt, const Point &rEndPt)
bool mbFillColor
Definition: outdev.hxx:381
VclPtr< VirtualDevice > mpAlphaVDev
Definition: outdev.hxx:330
void AddAction(const rtl::Reference< MetaAction > &pAction)
Definition: gdimtf.cxx:564
bool mbInitClipRegion
Definition: outdev.hxx:386
virtual void InitClipRegion()
bool mbInitFillColor
Definition: outdev.hxx:383
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:376
tools::Long GetHeight() const
bool IsDeviceOutputNecessary() const
Definition: outdev.hxx:605
Point Center() const
GDIMetaFile * mpMetaFile
Definition: outdev.hxx:318