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 {
31  assert(!is_double_buffered_window());
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;
46 
47  if ( mbInitClipRegion )
49  if ( mbOutputClipped )
50  return;
51 
52  if ( mbInitLineColor )
53  InitLineColor();
54 
55  tools::Polygon aRectPoly( aRect.Center(), aRect.GetWidth() >> 1, aRect.GetHeight() >> 1 );
56  if ( aRectPoly.GetSize() >= 2 )
57  {
58  SalPoint* pPtAry = reinterpret_cast<SalPoint*>(aRectPoly.GetPointAry());
59  if ( !mbFillColor )
60  mpGraphics->DrawPolyLine( aRectPoly.GetSize(), pPtAry, this );
61  else
62  {
63  if ( mbInitFillColor )
64  InitFillColor();
65  mpGraphics->DrawPolygon( aRectPoly.GetSize(), pPtAry, this );
66  }
67  }
68 
69  if( mpAlphaVDev )
70  mpAlphaVDev->DrawEllipse( rRect );
71 }
72 
74  const Point& rStartPt, const Point& rEndPt )
75 {
76  assert(!is_double_buffered_window());
77 
78  if ( mpMetaFile )
79  mpMetaFile->AddAction( new MetaArcAction( rRect, rStartPt, rEndPt ) );
80 
82  return;
83 
84  tools::Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
85  if ( aRect.IsEmpty() )
86  return;
87 
88  // we need a graphics
89  if ( !mpGraphics && !AcquireGraphics() )
90  return;
91 
92  if ( mbInitClipRegion )
94  if ( mbOutputClipped )
95  return;
96 
97  if ( mbInitLineColor )
98  InitLineColor();
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  SalPoint* pPtAry = reinterpret_cast<SalPoint*>(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 
125  tools::Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
126  if ( aRect.IsEmpty() )
127  return;
128 
129  // we need a graphics
130  if ( !mpGraphics && !AcquireGraphics() )
131  return;
132 
133  if ( mbInitClipRegion )
134  InitClipRegion();
135  if ( mbOutputClipped )
136  return;
137 
138  if ( mbInitLineColor )
139  InitLineColor();
140 
141  const Point aStart( ImplLogicToDevicePixel( rStartPt ) );
142  const Point aEnd( ImplLogicToDevicePixel( rEndPt ) );
143  tools::Polygon aPiePoly( aRect, aStart, aEnd, PolyStyle::Pie );
144 
145  if ( aPiePoly.GetSize() >= 2 )
146  {
147  SalPoint* pPtAry = reinterpret_cast<SalPoint*>(aPiePoly.GetPointAry());
148  if ( !mbFillColor )
149  mpGraphics->DrawPolyLine( aPiePoly.GetSize(), pPtAry, this );
150  else
151  {
152  if ( mbInitFillColor )
153  InitFillColor();
154  mpGraphics->DrawPolygon( aPiePoly.GetSize(), pPtAry, this );
155  }
156  }
157 
158  if( mpAlphaVDev )
159  mpAlphaVDev->DrawPie( rRect, rStartPt, rEndPt );
160 }
161 
163  const Point& rStartPt, const Point& rEndPt )
164 {
165  assert(!is_double_buffered_window());
166 
167  if ( mpMetaFile )
168  mpMetaFile->AddAction( new MetaChordAction( rRect, rStartPt, rEndPt ) );
169 
171  return;
172 
173  tools::Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
174  if ( aRect.IsEmpty() )
175  return;
176 
177  // we need a graphics
178  if ( !mpGraphics && !AcquireGraphics() )
179  return;
180 
181  if ( mbInitClipRegion )
182  InitClipRegion();
183  if ( mbOutputClipped )
184  return;
185 
186  if ( mbInitLineColor )
187  InitLineColor();
188 
189  const Point aStart( ImplLogicToDevicePixel( rStartPt ) );
190  const Point aEnd( ImplLogicToDevicePixel( rEndPt ) );
191  tools::Polygon aChordPoly( aRect, aStart, aEnd, PolyStyle::Chord );
192 
193  if ( aChordPoly.GetSize() >= 2 )
194  {
195  SalPoint* pPtAry = reinterpret_cast<SalPoint*>(aChordPoly.GetPointAry());
196  if ( !mbFillColor )
197  mpGraphics->DrawPolyLine( aChordPoly.GetSize(), pPtAry, this );
198  else
199  {
200  if ( mbInitFillColor )
201  InitFillColor();
202  mpGraphics->DrawPolygon( aChordPoly.GetSize(), pPtAry, this );
203  }
204  }
205 
206  if( mpAlphaVDev )
207  mpAlphaVDev->DrawChord( rRect, rStartPt, rEndPt );
208 }
209 
210 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
long GetWidth() const
long GetHeight() const
SAL_DLLPRIVATE bool ImplIsRecordLayout() const
Definition: outdev.cxx:657
bool mbOutputClipped
Definition: outdev.hxx:381
void DrawChord(const tools::Rectangle &rRect, const Point &rStartPt, const Point &rEndPt)
SAL_DLLPRIVATE bool is_double_buffered_window() const
bool IsEmpty() const
SAL_DLLPRIVATE void InitLineColor()
void DrawPolyLine(sal_uInt32 nPoints, SalPoint const *pPtAry, const OutputDevice *pOutDev)
void DrawPolygon(sal_uInt32 nPoints, const SalPoint *pPtAry, const OutputDevice *pOutDev)
SalGraphics * mpGraphics
Graphics context to draw on.
Definition: outdev.hxx:316
SAL_DLLPRIVATE void InitFillColor()
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:384
bool mbLineColor
Definition: outdev.hxx:382
sal_uInt16 GetSize() const
void DrawPie(const tools::Rectangle &rRect, const Point &rStartPt, const Point &rEndPt)
bool mbFillColor
Definition: outdev.hxx:383
VclPtr< VirtualDevice > mpAlphaVDev
Definition: outdev.hxx:331
void AddAction(const rtl::Reference< MetaAction > &pAction)
Definition: gdimtf.cxx:539
bool mbInitClipRegion
Definition: outdev.hxx:388
virtual void InitClipRegion()
bool mbInitFillColor
Definition: outdev.hxx:385
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:504
bool IsDeviceOutputNecessary() const
Definition: outdev.hxx:589
Point Center() const
GDIMetaFile * mpMetaFile
Definition: outdev.hxx:319