1ff12d537SAndre Fischer /************************************************************** 2ff12d537SAndre Fischer * 3ff12d537SAndre Fischer * Licensed to the Apache Software Foundation (ASF) under one 4ff12d537SAndre Fischer * or more contributor license agreements. See the NOTICE file 5ff12d537SAndre Fischer * distributed with this work for additional information 6ff12d537SAndre Fischer * regarding copyright ownership. The ASF licenses this file 7ff12d537SAndre Fischer * to you under the Apache License, Version 2.0 (the 8ff12d537SAndre Fischer * "License"); you may not use this file except in compliance 9ff12d537SAndre Fischer * with the License. You may obtain a copy of the License at 10ff12d537SAndre Fischer * 11ff12d537SAndre Fischer * http://www.apache.org/licenses/LICENSE-2.0 12ff12d537SAndre Fischer * 13ff12d537SAndre Fischer * Unless required by applicable law or agreed to in writing, 14ff12d537SAndre Fischer * software distributed under the License is distributed on an 15ff12d537SAndre Fischer * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16ff12d537SAndre Fischer * KIND, either express or implied. See the License for the 17ff12d537SAndre Fischer * specific language governing permissions and limitations 18ff12d537SAndre Fischer * under the License. 19ff12d537SAndre Fischer * 20ff12d537SAndre Fischer *************************************************************/ 21ff12d537SAndre Fischer 22ff12d537SAndre Fischer #include "precompiled_sfx2.hxx" 23ff12d537SAndre Fischer 24ff12d537SAndre Fischer #include "DrawHelper.hxx" 25ff12d537SAndre Fischer #include "Paint.hxx" 26ff12d537SAndre Fischer 27ff12d537SAndre Fischer #include <vcl/lineinfo.hxx> 28ff12d537SAndre Fischer 29ff12d537SAndre Fischer 30ff12d537SAndre Fischer namespace sfx2 { namespace sidebar { 31ff12d537SAndre Fischer 32ff12d537SAndre Fischer void DrawHelper::DrawBorder ( 33ff12d537SAndre Fischer OutputDevice& rDevice, 34ff12d537SAndre Fischer const Rectangle rBox, 35ff12d537SAndre Fischer const SvBorder aBorderSize, 36ff12d537SAndre Fischer const Paint& rHorizontalPaint, 37ff12d537SAndre Fischer const Paint& rVerticalPaint) 38ff12d537SAndre Fischer { 39ff12d537SAndre Fischer // Draw top line. 40ff12d537SAndre Fischer DrawHorizontalLine( 41ff12d537SAndre Fischer rDevice, 42ff12d537SAndre Fischer rBox.Left(), 43ff12d537SAndre Fischer rBox.Right(), 44ff12d537SAndre Fischer rBox.Top(), 45ff12d537SAndre Fischer aBorderSize.Top(), 46ff12d537SAndre Fischer rHorizontalPaint); 47ff12d537SAndre Fischer // Draw bottom line. 48ff12d537SAndre Fischer DrawHorizontalLine( 49ff12d537SAndre Fischer rDevice, 50*b9e67834SAndre Fischer rBox.Left()+aBorderSize.Left(), 51ff12d537SAndre Fischer rBox.Right(), 52ff12d537SAndre Fischer rBox.Bottom()-aBorderSize.Bottom()+1, 53ff12d537SAndre Fischer aBorderSize.Bottom(), 54ff12d537SAndre Fischer rHorizontalPaint); 55ff12d537SAndre Fischer // Draw left line. 56ff12d537SAndre Fischer DrawVerticalLine( 57ff12d537SAndre Fischer rDevice, 58ff12d537SAndre Fischer rBox.Top()+aBorderSize.Top(), 59*b9e67834SAndre Fischer rBox.Bottom(), 60ff12d537SAndre Fischer rBox.Left(), 61ff12d537SAndre Fischer aBorderSize.Left(), 62ff12d537SAndre Fischer rVerticalPaint); 63ff12d537SAndre Fischer // Draw right line. 64ff12d537SAndre Fischer DrawVerticalLine( 65ff12d537SAndre Fischer rDevice, 66*b9e67834SAndre Fischer rBox.Top()+aBorderSize.Top(), 67*b9e67834SAndre Fischer rBox.Bottom()-aBorderSize.Bottom(), 68ff12d537SAndre Fischer rBox.Right()-aBorderSize.Right()+1, 69ff12d537SAndre Fischer aBorderSize.Right(), 70ff12d537SAndre Fischer rVerticalPaint); 71ff12d537SAndre Fischer } 72ff12d537SAndre Fischer 73ff12d537SAndre Fischer 74ff12d537SAndre Fischer 75ff12d537SAndre Fischer 76ff12d537SAndre Fischer void DrawHelper::DrawHorizontalLine( 77ff12d537SAndre Fischer OutputDevice& rDevice, 78*b9e67834SAndre Fischer const sal_Int32 nLeft, 79*b9e67834SAndre Fischer const sal_Int32 nRight, 80*b9e67834SAndre Fischer const sal_Int32 nY, 81*b9e67834SAndre Fischer const sal_Int32 nHeight, 82ff12d537SAndre Fischer const Paint& rPaint) 83ff12d537SAndre Fischer { 84ff12d537SAndre Fischer switch (rPaint.GetType()) 85ff12d537SAndre Fischer { 86ff12d537SAndre Fischer case Paint::NoPaint: 87ff12d537SAndre Fischer default: 88ff12d537SAndre Fischer break; 89ff12d537SAndre Fischer 90ff12d537SAndre Fischer case Paint::ColorPaint: 91*b9e67834SAndre Fischer { 92*b9e67834SAndre Fischer const Color aColor (rPaint.GetColor()); 93*b9e67834SAndre Fischer rDevice.SetLineColor(aColor); 94*b9e67834SAndre Fischer for (sal_Int32 nYOffset=0; nYOffset<nHeight; ++nYOffset) 95ff12d537SAndre Fischer rDevice.DrawLine( 96*b9e67834SAndre Fischer Point(nLeft,nY+nYOffset), 97*b9e67834SAndre Fischer Point(nRight,nY+nYOffset)); 98ff12d537SAndre Fischer break; 99*b9e67834SAndre Fischer } 100ff12d537SAndre Fischer case Paint::GradientPaint: 101ff12d537SAndre Fischer rDevice.DrawGradient( 102ff12d537SAndre Fischer Rectangle( 103ff12d537SAndre Fischer nLeft, 104ff12d537SAndre Fischer nY, 105ff12d537SAndre Fischer nRight, 106ff12d537SAndre Fischer nY+nHeight-1), 107ff12d537SAndre Fischer rPaint.GetGradient()); 108ff12d537SAndre Fischer break; 109ff12d537SAndre Fischer } 110ff12d537SAndre Fischer } 111ff12d537SAndre Fischer 112ff12d537SAndre Fischer 113ff12d537SAndre Fischer 114ff12d537SAndre Fischer 115ff12d537SAndre Fischer void DrawHelper::DrawVerticalLine( 116ff12d537SAndre Fischer OutputDevice& rDevice, 117*b9e67834SAndre Fischer const sal_Int32 nTop, 118*b9e67834SAndre Fischer const sal_Int32 nBottom, 119*b9e67834SAndre Fischer const sal_Int32 nX, 120*b9e67834SAndre Fischer const sal_Int32 nWidth, 121ff12d537SAndre Fischer const Paint& rPaint) 122ff12d537SAndre Fischer { 123ff12d537SAndre Fischer switch (rPaint.GetType()) 124ff12d537SAndre Fischer { 125ff12d537SAndre Fischer case Paint::NoPaint: 126ff12d537SAndre Fischer default: 127ff12d537SAndre Fischer break; 128ff12d537SAndre Fischer 129ff12d537SAndre Fischer case Paint::ColorPaint: 130*b9e67834SAndre Fischer { 131*b9e67834SAndre Fischer const Color aColor (rPaint.GetColor()); 132*b9e67834SAndre Fischer rDevice.SetLineColor(aColor); 133*b9e67834SAndre Fischer for (sal_Int32 nXOffset=0; nXOffset<nWidth; ++nXOffset) 134ff12d537SAndre Fischer rDevice.DrawLine( 135*b9e67834SAndre Fischer Point(nX+nXOffset, nTop), 136*b9e67834SAndre Fischer Point(nX+nXOffset, nBottom)); 137ff12d537SAndre Fischer break; 138*b9e67834SAndre Fischer } 139ff12d537SAndre Fischer case Paint::GradientPaint: 140ff12d537SAndre Fischer rDevice.DrawGradient( 141ff12d537SAndre Fischer Rectangle( 142ff12d537SAndre Fischer nX, 143ff12d537SAndre Fischer nTop, 144ff12d537SAndre Fischer nX+nWidth-1, 145ff12d537SAndre Fischer nBottom), 146ff12d537SAndre Fischer rPaint.GetGradient()); 147ff12d537SAndre Fischer break; 148ff12d537SAndre Fischer } 149ff12d537SAndre Fischer } 150ff12d537SAndre Fischer 151ff12d537SAndre Fischer 152ff12d537SAndre Fischer 153ff12d537SAndre Fischer 154ff12d537SAndre Fischer void DrawHelper::DrawRoundedRectangle ( 155ff12d537SAndre Fischer OutputDevice& rDevice, 156ff12d537SAndre Fischer const Rectangle& rBox, 157*b9e67834SAndre Fischer const sal_Int32 nCornerRadius, 158ff12d537SAndre Fischer const Color& rBorderColor, 159ff12d537SAndre Fischer const Paint& rFillPaint) 160ff12d537SAndre Fischer { 161ff12d537SAndre Fischer rDevice.SetLineColor(rBorderColor); 162ff12d537SAndre Fischer switch(rFillPaint.GetType()) 163ff12d537SAndre Fischer { 164ff12d537SAndre Fischer case Paint::NoPaint: 165ff12d537SAndre Fischer default: 166ff12d537SAndre Fischer rDevice.SetFillColor(); 167ff12d537SAndre Fischer rDevice.DrawRect(rBox, nCornerRadius, nCornerRadius); 168ff12d537SAndre Fischer break; 169ff12d537SAndre Fischer 170ff12d537SAndre Fischer case Paint::ColorPaint: 171ff12d537SAndre Fischer rDevice.SetFillColor(rFillPaint.GetColor()); 172ff12d537SAndre Fischer rDevice.DrawRect(rBox, nCornerRadius, nCornerRadius); 173ff12d537SAndre Fischer break; 174ff12d537SAndre Fischer 175ff12d537SAndre Fischer case Paint::GradientPaint: 176ff12d537SAndre Fischer rDevice.DrawGradient( 177ff12d537SAndre Fischer rBox, 178ff12d537SAndre Fischer rFillPaint.GetGradient()); 179ff12d537SAndre Fischer rDevice.SetFillColor(); 180ff12d537SAndre Fischer rDevice.DrawRect(rBox, nCornerRadius, nCornerRadius); 181ff12d537SAndre Fischer break; 182ff12d537SAndre Fischer } 183ff12d537SAndre Fischer } 184ff12d537SAndre Fischer 185ff12d537SAndre Fischer 186ff12d537SAndre Fischer 187ff12d537SAndre Fischer } } // end of namespace sfx2::sidebar 188