1*9f62ea84SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*9f62ea84SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*9f62ea84SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*9f62ea84SAndrew Rist * distributed with this work for additional information 6*9f62ea84SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*9f62ea84SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*9f62ea84SAndrew Rist * "License"); you may not use this file except in compliance 9*9f62ea84SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*9f62ea84SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*9f62ea84SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*9f62ea84SAndrew Rist * software distributed under the License is distributed on an 15*9f62ea84SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*9f62ea84SAndrew Rist * KIND, either express or implied. See the License for the 17*9f62ea84SAndrew Rist * specific language governing permissions and limitations 18*9f62ea84SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*9f62ea84SAndrew Rist *************************************************************/ 21*9f62ea84SAndrew Rist 22*9f62ea84SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_vcl.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <tools/ref.hxx> 28cdf0e10cSrcweir #include <tools/debug.hxx> 29cdf0e10cSrcweir #include <tools/poly.hxx> 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <vcl/metaact.hxx> 32cdf0e10cSrcweir #include <vcl/gdimtf.hxx> 33cdf0e10cSrcweir #include <vcl/outdev.hxx> 34cdf0e10cSrcweir #include <vcl/virdev.hxx> 35cdf0e10cSrcweir 36cdf0e10cSrcweir #include <salgdi.hxx> 37cdf0e10cSrcweir #include <svdata.hxx> 38cdf0e10cSrcweir #include <outdata.hxx> 39cdf0e10cSrcweir #include <outdev.h> 40cdf0e10cSrcweir 41cdf0e10cSrcweir // ======================================================================= 42cdf0e10cSrcweir 43cdf0e10cSrcweir DBG_NAMEEX( OutputDevice ) 44cdf0e10cSrcweir 45cdf0e10cSrcweir // ======================================================================= 46cdf0e10cSrcweir 47cdf0e10cSrcweir void OutputDevice::DrawRect( const Rectangle& rRect, 48cdf0e10cSrcweir sal_uLong nHorzRound, sal_uLong nVertRound ) 49cdf0e10cSrcweir { 50cdf0e10cSrcweir DBG_TRACE( "OutputDevice::DrawRoundRect()" ); 51cdf0e10cSrcweir DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); 52cdf0e10cSrcweir 53cdf0e10cSrcweir if ( mpMetaFile ) 54cdf0e10cSrcweir mpMetaFile->AddAction( new MetaRoundRectAction( rRect, nHorzRound, nVertRound ) ); 55cdf0e10cSrcweir 56cdf0e10cSrcweir if ( !IsDeviceOutputNecessary() || (!mbLineColor && !mbFillColor) || ImplIsRecordLayout() ) 57cdf0e10cSrcweir return; 58cdf0e10cSrcweir 59cdf0e10cSrcweir const Rectangle aRect( ImplLogicToDevicePixel( rRect ) ); 60cdf0e10cSrcweir 61cdf0e10cSrcweir if ( aRect.IsEmpty() ) 62cdf0e10cSrcweir return; 63cdf0e10cSrcweir 64cdf0e10cSrcweir nHorzRound = ImplLogicWidthToDevicePixel( nHorzRound ); 65cdf0e10cSrcweir nVertRound = ImplLogicHeightToDevicePixel( nVertRound ); 66cdf0e10cSrcweir 67cdf0e10cSrcweir // we need a graphics 68cdf0e10cSrcweir if ( !mpGraphics ) 69cdf0e10cSrcweir { 70cdf0e10cSrcweir if ( !ImplGetGraphics() ) 71cdf0e10cSrcweir return; 72cdf0e10cSrcweir } 73cdf0e10cSrcweir 74cdf0e10cSrcweir if ( mbInitClipRegion ) 75cdf0e10cSrcweir ImplInitClipRegion(); 76cdf0e10cSrcweir if ( mbOutputClipped ) 77cdf0e10cSrcweir return; 78cdf0e10cSrcweir 79cdf0e10cSrcweir if ( mbInitLineColor ) 80cdf0e10cSrcweir ImplInitLineColor(); 81cdf0e10cSrcweir if ( mbInitFillColor ) 82cdf0e10cSrcweir ImplInitFillColor(); 83cdf0e10cSrcweir 84cdf0e10cSrcweir if ( !nHorzRound && !nVertRound ) 85cdf0e10cSrcweir mpGraphics->DrawRect( aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight(), this ); 86cdf0e10cSrcweir else 87cdf0e10cSrcweir { 88cdf0e10cSrcweir const Polygon aRoundRectPoly( aRect, nHorzRound, nVertRound ); 89cdf0e10cSrcweir 90cdf0e10cSrcweir if ( aRoundRectPoly.GetSize() >= 2 ) 91cdf0e10cSrcweir { 92cdf0e10cSrcweir const SalPoint* pPtAry = (const SalPoint*) aRoundRectPoly.GetConstPointAry(); 93cdf0e10cSrcweir 94cdf0e10cSrcweir if ( !mbFillColor ) 95cdf0e10cSrcweir mpGraphics->DrawPolyLine( aRoundRectPoly.GetSize(), pPtAry, this ); 96cdf0e10cSrcweir else 97cdf0e10cSrcweir mpGraphics->DrawPolygon( aRoundRectPoly.GetSize(), pPtAry, this ); 98cdf0e10cSrcweir } 99cdf0e10cSrcweir } 100cdf0e10cSrcweir 101cdf0e10cSrcweir if( mpAlphaVDev ) 102cdf0e10cSrcweir mpAlphaVDev->DrawRect( rRect, nHorzRound, nVertRound ); 103cdf0e10cSrcweir } 104cdf0e10cSrcweir 105cdf0e10cSrcweir // ----------------------------------------------------------------------- 106cdf0e10cSrcweir 107cdf0e10cSrcweir void OutputDevice::DrawEllipse( const Rectangle& rRect ) 108cdf0e10cSrcweir { 109cdf0e10cSrcweir DBG_TRACE( "OutputDevice::DrawEllipse()" ); 110cdf0e10cSrcweir DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); 111cdf0e10cSrcweir 112cdf0e10cSrcweir if ( mpMetaFile ) 113cdf0e10cSrcweir mpMetaFile->AddAction( new MetaEllipseAction( rRect ) ); 114cdf0e10cSrcweir 115cdf0e10cSrcweir if ( !IsDeviceOutputNecessary() || (!mbLineColor && !mbFillColor) || ImplIsRecordLayout() ) 116cdf0e10cSrcweir return; 117cdf0e10cSrcweir 118cdf0e10cSrcweir Rectangle aRect( ImplLogicToDevicePixel( rRect ) ); 119cdf0e10cSrcweir if ( aRect.IsEmpty() ) 120cdf0e10cSrcweir return; 121cdf0e10cSrcweir 122cdf0e10cSrcweir // we need a graphics 123cdf0e10cSrcweir if ( !mpGraphics ) 124cdf0e10cSrcweir { 125cdf0e10cSrcweir if ( !ImplGetGraphics() ) 126cdf0e10cSrcweir return; 127cdf0e10cSrcweir } 128cdf0e10cSrcweir 129cdf0e10cSrcweir if ( mbInitClipRegion ) 130cdf0e10cSrcweir ImplInitClipRegion(); 131cdf0e10cSrcweir if ( mbOutputClipped ) 132cdf0e10cSrcweir return; 133cdf0e10cSrcweir 134cdf0e10cSrcweir if ( mbInitLineColor ) 135cdf0e10cSrcweir ImplInitLineColor(); 136cdf0e10cSrcweir 137cdf0e10cSrcweir Polygon aRectPoly( aRect.Center(), aRect.GetWidth() >> 1, aRect.GetHeight() >> 1 ); 138cdf0e10cSrcweir if ( aRectPoly.GetSize() >= 2 ) 139cdf0e10cSrcweir { 140cdf0e10cSrcweir const SalPoint* pPtAry = (const SalPoint*)aRectPoly.GetConstPointAry(); 141cdf0e10cSrcweir if ( !mbFillColor ) 142cdf0e10cSrcweir mpGraphics->DrawPolyLine( aRectPoly.GetSize(), pPtAry, this ); 143cdf0e10cSrcweir else 144cdf0e10cSrcweir { 145cdf0e10cSrcweir if ( mbInitFillColor ) 146cdf0e10cSrcweir ImplInitFillColor(); 147cdf0e10cSrcweir mpGraphics->DrawPolygon( aRectPoly.GetSize(), pPtAry, this ); 148cdf0e10cSrcweir } 149cdf0e10cSrcweir } 150cdf0e10cSrcweir 151cdf0e10cSrcweir if( mpAlphaVDev ) 152cdf0e10cSrcweir mpAlphaVDev->DrawEllipse( rRect ); 153cdf0e10cSrcweir } 154cdf0e10cSrcweir 155cdf0e10cSrcweir // ----------------------------------------------------------------------- 156cdf0e10cSrcweir 157cdf0e10cSrcweir void OutputDevice::DrawArc( const Rectangle& rRect, 158cdf0e10cSrcweir const Point& rStartPt, const Point& rEndPt ) 159cdf0e10cSrcweir { 160cdf0e10cSrcweir DBG_TRACE( "OutputDevice::DrawArc()" ); 161cdf0e10cSrcweir DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); 162cdf0e10cSrcweir 163cdf0e10cSrcweir if ( mpMetaFile ) 164cdf0e10cSrcweir mpMetaFile->AddAction( new MetaArcAction( rRect, rStartPt, rEndPt ) ); 165cdf0e10cSrcweir 166cdf0e10cSrcweir if ( !IsDeviceOutputNecessary() || !mbLineColor || ImplIsRecordLayout() ) 167cdf0e10cSrcweir return; 168cdf0e10cSrcweir 169cdf0e10cSrcweir Rectangle aRect( ImplLogicToDevicePixel( rRect ) ); 170cdf0e10cSrcweir if ( aRect.IsEmpty() ) 171cdf0e10cSrcweir return; 172cdf0e10cSrcweir 173cdf0e10cSrcweir // we need a graphics 174cdf0e10cSrcweir if ( !mpGraphics ) 175cdf0e10cSrcweir { 176cdf0e10cSrcweir if ( !ImplGetGraphics() ) 177cdf0e10cSrcweir return; 178cdf0e10cSrcweir } 179cdf0e10cSrcweir 180cdf0e10cSrcweir if ( mbInitClipRegion ) 181cdf0e10cSrcweir ImplInitClipRegion(); 182cdf0e10cSrcweir if ( mbOutputClipped ) 183cdf0e10cSrcweir return; 184cdf0e10cSrcweir 185cdf0e10cSrcweir if ( mbInitLineColor ) 186cdf0e10cSrcweir ImplInitLineColor(); 187cdf0e10cSrcweir 188cdf0e10cSrcweir const Point aStart( ImplLogicToDevicePixel( rStartPt ) ); 189cdf0e10cSrcweir const Point aEnd( ImplLogicToDevicePixel( rEndPt ) ); 190cdf0e10cSrcweir Polygon aArcPoly( aRect, aStart, aEnd, POLY_ARC ); 191cdf0e10cSrcweir 192cdf0e10cSrcweir if ( aArcPoly.GetSize() >= 2 ) 193cdf0e10cSrcweir { 194cdf0e10cSrcweir const SalPoint* pPtAry = (const SalPoint*)aArcPoly.GetConstPointAry(); 195cdf0e10cSrcweir mpGraphics->DrawPolyLine( aArcPoly.GetSize(), pPtAry, this ); 196cdf0e10cSrcweir } 197cdf0e10cSrcweir 198cdf0e10cSrcweir if( mpAlphaVDev ) 199cdf0e10cSrcweir mpAlphaVDev->DrawArc( rRect, rStartPt, rEndPt ); 200cdf0e10cSrcweir } 201cdf0e10cSrcweir 202cdf0e10cSrcweir // ----------------------------------------------------------------------- 203cdf0e10cSrcweir 204cdf0e10cSrcweir void OutputDevice::DrawPie( const Rectangle& rRect, 205cdf0e10cSrcweir const Point& rStartPt, const Point& rEndPt ) 206cdf0e10cSrcweir { 207cdf0e10cSrcweir DBG_TRACE( "OutputDevice::DrawPie()" ); 208cdf0e10cSrcweir DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); 209cdf0e10cSrcweir 210cdf0e10cSrcweir if ( mpMetaFile ) 211cdf0e10cSrcweir mpMetaFile->AddAction( new MetaPieAction( rRect, rStartPt, rEndPt ) ); 212cdf0e10cSrcweir 213cdf0e10cSrcweir if ( !IsDeviceOutputNecessary() || (!mbLineColor && !mbFillColor) || ImplIsRecordLayout() ) 214cdf0e10cSrcweir return; 215cdf0e10cSrcweir 216cdf0e10cSrcweir Rectangle aRect( ImplLogicToDevicePixel( rRect ) ); 217cdf0e10cSrcweir if ( aRect.IsEmpty() ) 218cdf0e10cSrcweir return; 219cdf0e10cSrcweir 220cdf0e10cSrcweir // we need a graphics 221cdf0e10cSrcweir if ( !mpGraphics ) 222cdf0e10cSrcweir { 223cdf0e10cSrcweir if ( !ImplGetGraphics() ) 224cdf0e10cSrcweir return; 225cdf0e10cSrcweir } 226cdf0e10cSrcweir 227cdf0e10cSrcweir if ( mbInitClipRegion ) 228cdf0e10cSrcweir ImplInitClipRegion(); 229cdf0e10cSrcweir if ( mbOutputClipped ) 230cdf0e10cSrcweir return; 231cdf0e10cSrcweir 232cdf0e10cSrcweir if ( mbInitLineColor ) 233cdf0e10cSrcweir ImplInitLineColor(); 234cdf0e10cSrcweir 235cdf0e10cSrcweir const Point aStart( ImplLogicToDevicePixel( rStartPt ) ); 236cdf0e10cSrcweir const Point aEnd( ImplLogicToDevicePixel( rEndPt ) ); 237cdf0e10cSrcweir Polygon aPiePoly( aRect, aStart, aEnd, POLY_PIE ); 238cdf0e10cSrcweir 239cdf0e10cSrcweir if ( aPiePoly.GetSize() >= 2 ) 240cdf0e10cSrcweir { 241cdf0e10cSrcweir const SalPoint* pPtAry = (const SalPoint*)aPiePoly.GetConstPointAry(); 242cdf0e10cSrcweir if ( !mbFillColor ) 243cdf0e10cSrcweir mpGraphics->DrawPolyLine( aPiePoly.GetSize(), pPtAry, this ); 244cdf0e10cSrcweir else 245cdf0e10cSrcweir { 246cdf0e10cSrcweir if ( mbInitFillColor ) 247cdf0e10cSrcweir ImplInitFillColor(); 248cdf0e10cSrcweir mpGraphics->DrawPolygon( aPiePoly.GetSize(), pPtAry, this ); 249cdf0e10cSrcweir } 250cdf0e10cSrcweir } 251cdf0e10cSrcweir 252cdf0e10cSrcweir if( mpAlphaVDev ) 253cdf0e10cSrcweir mpAlphaVDev->DrawPie( rRect, rStartPt, rEndPt ); 254cdf0e10cSrcweir } 255cdf0e10cSrcweir 256cdf0e10cSrcweir // ----------------------------------------------------------------------- 257cdf0e10cSrcweir 258cdf0e10cSrcweir void OutputDevice::DrawChord( const Rectangle& rRect, 259cdf0e10cSrcweir const Point& rStartPt, const Point& rEndPt ) 260cdf0e10cSrcweir { 261cdf0e10cSrcweir DBG_TRACE( "OutputDevice::DrawChord()" ); 262cdf0e10cSrcweir DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); 263cdf0e10cSrcweir 264cdf0e10cSrcweir if ( mpMetaFile ) 265cdf0e10cSrcweir mpMetaFile->AddAction( new MetaChordAction( rRect, rStartPt, rEndPt ) ); 266cdf0e10cSrcweir 267cdf0e10cSrcweir if ( !IsDeviceOutputNecessary() || (!mbLineColor && !mbFillColor) || ImplIsRecordLayout() ) 268cdf0e10cSrcweir return; 269cdf0e10cSrcweir 270cdf0e10cSrcweir Rectangle aRect( ImplLogicToDevicePixel( rRect ) ); 271cdf0e10cSrcweir if ( aRect.IsEmpty() ) 272cdf0e10cSrcweir return; 273cdf0e10cSrcweir 274cdf0e10cSrcweir // we need a graphics 275cdf0e10cSrcweir if ( !mpGraphics ) 276cdf0e10cSrcweir { 277cdf0e10cSrcweir if ( !ImplGetGraphics() ) 278cdf0e10cSrcweir return; 279cdf0e10cSrcweir } 280cdf0e10cSrcweir 281cdf0e10cSrcweir if ( mbInitClipRegion ) 282cdf0e10cSrcweir ImplInitClipRegion(); 283cdf0e10cSrcweir if ( mbOutputClipped ) 284cdf0e10cSrcweir return; 285cdf0e10cSrcweir 286cdf0e10cSrcweir if ( mbInitLineColor ) 287cdf0e10cSrcweir ImplInitLineColor(); 288cdf0e10cSrcweir 289cdf0e10cSrcweir const Point aStart( ImplLogicToDevicePixel( rStartPt ) ); 290cdf0e10cSrcweir const Point aEnd( ImplLogicToDevicePixel( rEndPt ) ); 291cdf0e10cSrcweir Polygon aChordPoly( aRect, aStart, aEnd, POLY_CHORD ); 292cdf0e10cSrcweir 293cdf0e10cSrcweir if ( aChordPoly.GetSize() >= 2 ) 294cdf0e10cSrcweir { 295cdf0e10cSrcweir const SalPoint* pPtAry = (const SalPoint*)aChordPoly.GetConstPointAry(); 296cdf0e10cSrcweir if ( !mbFillColor ) 297cdf0e10cSrcweir mpGraphics->DrawPolyLine( aChordPoly.GetSize(), pPtAry, this ); 298cdf0e10cSrcweir else 299cdf0e10cSrcweir { 300cdf0e10cSrcweir if ( mbInitFillColor ) 301cdf0e10cSrcweir ImplInitFillColor(); 302cdf0e10cSrcweir mpGraphics->DrawPolygon( aChordPoly.GetSize(), pPtAry, this ); 303cdf0e10cSrcweir } 304cdf0e10cSrcweir } 305cdf0e10cSrcweir 306cdf0e10cSrcweir if( mpAlphaVDev ) 307cdf0e10cSrcweir mpAlphaVDev->DrawChord( rRect, rStartPt, rEndPt ); 308cdf0e10cSrcweir } 309