1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_BORDERLINEPRIMITIVE2D_HXX 25 #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_BORDERLINEPRIMITIVE2D_HXX 26 27 #include <drawinglayer/drawinglayerdllapi.h> 28 #include <drawinglayer/primitive2d/baseprimitive2d.hxx> 29 #include <basegfx/color/bcolor.hxx> 30 #include <basegfx/matrix/b2dhommatrix.hxx> 31 32 ////////////////////////////////////////////////////////////////////////////// 33 34 namespace drawinglayer 35 { 36 namespace primitive2d 37 { 38 /** BorderLinePrimitive2D class 39 40 This is the basic primitive to build frames around objects, e.g. tables. 41 It defines a single or double line from Start to nd using the LeftWidth, 42 Distance and RightWidth definitions. 43 The LineStart/End overlap is defined by the Extend(Inner|Outer)(Start|End) 44 definitions. 45 */ 46 class DRAWINGLAYER_DLLPUBLIC BorderLinePrimitive2D : public BufferedDecompositionPrimitive2D 47 { 48 private: 49 /// the line definition 50 basegfx::B2DPoint maStart; 51 basegfx::B2DPoint maEnd; 52 53 /// the widths of single/double line 54 double mfLeftWidth; 55 double mfDistance; 56 double mfRightWidth; 57 58 /// edge overlap sizes 59 double mfExtendInnerStart; 60 double mfExtendInnerEnd; 61 double mfExtendOuterStart; 62 double mfExtendOuterEnd; 63 64 /// the line color 65 basegfx::BColor maRGBColor; 66 67 /// bitfield 68 /// flags to influence inside/outside creation 69 unsigned mbCreateInside : 1; 70 unsigned mbCreateOutside : 1; 71 72 /// local helpers getCorrectedLeftWidth() const73 double getCorrectedLeftWidth() const 74 { 75 return basegfx::fTools::equal(1.0, mfLeftWidth) ? 0.0 : mfLeftWidth; 76 } 77 getCorrectedDistance() const78 double getCorrectedDistance() const 79 { 80 return basegfx::fTools::equal(1.0, mfDistance) ? 0.0 : mfDistance; 81 } 82 getCorrectedRightWidth() const83 double getCorrectedRightWidth() const 84 { 85 return basegfx::fTools::equal(1.0, mfRightWidth) ? 0.0 : mfRightWidth; 86 } 87 getWidth() const88 double getWidth() const 89 { 90 return getCorrectedLeftWidth() + getCorrectedDistance() + getCorrectedRightWidth(); 91 } 92 leftIsHairline() const93 bool leftIsHairline() const 94 { 95 return basegfx::fTools::equal(1.0, mfLeftWidth); 96 } 97 rightIsHairline() const98 bool rightIsHairline() const 99 { 100 return basegfx::fTools::equal(1.0, mfRightWidth); 101 } 102 isInsideUsed() const103 bool isInsideUsed() const 104 { 105 return !basegfx::fTools::equalZero(mfLeftWidth); 106 } 107 isOutsideUsed() const108 bool isOutsideUsed() const 109 { 110 return !basegfx::fTools::equalZero(mfRightWidth); 111 } 112 113 protected: 114 /// create local decomposition 115 virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; 116 117 public: 118 /// constructor 119 BorderLinePrimitive2D( 120 const basegfx::B2DPoint& rStart, 121 const basegfx::B2DPoint& rEnd, 122 double fLeftWidth, 123 double fDistance, 124 double fRightWidth, 125 double fExtendInnerStart, 126 double fExtendInnerEnd, 127 double fExtendOuterStart, 128 double fExtendOuterEnd, 129 bool bCreateInside, 130 bool bCreateOutside, 131 const basegfx::BColor& rRGBColor); 132 133 /// data read access getStart() const134 const basegfx::B2DPoint& getStart() const { return maStart; } getEnd() const135 const basegfx::B2DPoint& getEnd() const { return maEnd; } getLeftWidth() const136 double getLeftWidth() const { return mfLeftWidth; } getDistance() const137 double getDistance() const { return mfDistance; } getRightWidth() const138 double getRightWidth() const { return mfRightWidth; } getExtendInnerStart() const139 double getExtendInnerStart() const { return mfExtendInnerStart; } getExtendInnerEnd() const140 double getExtendInnerEnd() const { return mfExtendInnerEnd; } getExtendOuterStart() const141 double getExtendOuterStart() const { return mfExtendOuterStart; } getExtendOuterEnd() const142 double getExtendOuterEnd() const { return mfExtendOuterEnd; } getCreateInside() const143 bool getCreateInside() const { return mbCreateInside; } getCreateOutside() const144 bool getCreateOutside() const { return mbCreateOutside; } getRGBColor() const145 const basegfx::BColor& getRGBColor() const { return maRGBColor; } 146 147 /// compare operator 148 virtual bool operator==(const BasePrimitive2D& rPrimitive) const; 149 150 /// provide unique ID 151 DeclPrimitrive2DIDBlock() 152 }; 153 } // end of namespace primitive2d 154 } // end of namespace drawinglayer 155 156 ////////////////////////////////////////////////////////////////////////////// 157 158 #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_BORDERLINEPRIMITIVE2D_HXX 159 160 ////////////////////////////////////////////////////////////////////////////// 161 // eof 162