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