1*c45d927aSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*c45d927aSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*c45d927aSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*c45d927aSAndrew Rist * distributed with this work for additional information 6*c45d927aSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*c45d927aSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*c45d927aSAndrew Rist * "License"); you may not use this file except in compliance 9*c45d927aSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*c45d927aSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*c45d927aSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*c45d927aSAndrew Rist * software distributed under the License is distributed on an 15*c45d927aSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*c45d927aSAndrew Rist * KIND, either express or implied. See the License for the 17*c45d927aSAndrew Rist * specific language governing permissions and limitations 18*c45d927aSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*c45d927aSAndrew Rist *************************************************************/ 21*c45d927aSAndrew Rist 22*c45d927aSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef SD_SLIDESORTER_VIEW_FRAME_PAINTER_HXX 25cdf0e10cSrcweir #define SD_SLIDESORTER_VIEW_FRAME_PAINTER_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <vcl/bitmapex.hxx> 28cdf0e10cSrcweir 29cdf0e10cSrcweir 30cdf0e10cSrcweir namespace sd { namespace slidesorter { namespace view { 31cdf0e10cSrcweir 32cdf0e10cSrcweir class FramePainter 33cdf0e10cSrcweir { 34cdf0e10cSrcweir public: 35cdf0e10cSrcweir FramePainter (const BitmapEx& rBitmap); 36cdf0e10cSrcweir ~FramePainter (void); 37cdf0e10cSrcweir 38cdf0e10cSrcweir /** Paint a border around the given box by using a set of bitmaps for 39cdf0e10cSrcweir the corners and sides. 40cdf0e10cSrcweir */ 41cdf0e10cSrcweir void PaintFrame (OutputDevice&rDevice, const Rectangle aBox) const; 42cdf0e10cSrcweir 43cdf0e10cSrcweir /** Special functionality that takes the color from the center 44cdf0e10cSrcweir bitmap and replaces that color in all bitmaps by the given new 45cdf0e10cSrcweir color. Alpha values are not modified. 46cdf0e10cSrcweir @param bClearCenterBitmap 47cdf0e10cSrcweir When <TRUE/> then the center bitmap is erased. 48cdf0e10cSrcweir */ 49cdf0e10cSrcweir void AdaptColor (const Color aNewColor, const bool bClearCenterBitmap); 50cdf0e10cSrcweir 51cdf0e10cSrcweir private: 52cdf0e10cSrcweir /** Bitmap with offset that is used when the bitmap is painted. The bitmap 53cdf0e10cSrcweir */ 54cdf0e10cSrcweir class OffsetBitmap { 55cdf0e10cSrcweir public: 56cdf0e10cSrcweir BitmapEx maBitmap; 57cdf0e10cSrcweir Point maOffset; 58cdf0e10cSrcweir 59cdf0e10cSrcweir /** Create one of the eight shadow bitmaps from one that combines 60cdf0e10cSrcweir them all. This larger bitmap is expected to have dimension NxN 61cdf0e10cSrcweir with N=1+2*M. Of this larger bitmap there are created four 62cdf0e10cSrcweir corner bitmaps of size 2*M x 2*M and four side bitmaps of sizes 63cdf0e10cSrcweir 1xM (top and bottom) and Mx1 (left and right). The corner 64cdf0e10cSrcweir bitmaps have each one quadrant of size MxM that is painted under 65cdf0e10cSrcweir the interior of the frame. 66cdf0e10cSrcweir @param rBitmap 67cdf0e10cSrcweir The larger bitmap of which the eight shadow bitmaps are cut 68cdf0e10cSrcweir out from. 69cdf0e10cSrcweir @param nHorizontalPosition 70cdf0e10cSrcweir Valid values are -1 (left), 0 (center), and +1 (right). 71cdf0e10cSrcweir @param nVerticalPosition 72cdf0e10cSrcweir Valid values are -1 (top), 0 (center), and +1 (bottom). 73cdf0e10cSrcweir */ 74cdf0e10cSrcweir OffsetBitmap ( 75cdf0e10cSrcweir const BitmapEx& rBitmap, 76cdf0e10cSrcweir const sal_Int32 nHorizontalPosition, 77cdf0e10cSrcweir const sal_Int32 nVerticalPosition); 78cdf0e10cSrcweir 79cdf0e10cSrcweir /** Use the given device to paint the bitmap at the location that is 80cdf0e10cSrcweir the sum of the given anchor and the internal offset. 81cdf0e10cSrcweir */ 82cdf0e10cSrcweir void PaintCorner (OutputDevice& rDevice, const Point& rAnchor) const; 83cdf0e10cSrcweir 84cdf0e10cSrcweir /** Use the given device to paint the bitmap stretched between the 85cdf0e10cSrcweir two given locations. Offsets of the adjacent corner bitmaps and 86cdf0e10cSrcweir the offset of the side bitmap are used to determine the area 87cdf0e10cSrcweir that is to be filled with the side bitmap. 88cdf0e10cSrcweir */ 89cdf0e10cSrcweir void PaintSide ( 90cdf0e10cSrcweir OutputDevice& rDevice, 91cdf0e10cSrcweir const Point& rAnchor1, 92cdf0e10cSrcweir const Point& rAnchor2, 93cdf0e10cSrcweir const OffsetBitmap& rCornerBitmap1, 94cdf0e10cSrcweir const OffsetBitmap& rCornerBitmap2) const; 95cdf0e10cSrcweir 96cdf0e10cSrcweir /** Fill the given rectangle with the bitmap. 97cdf0e10cSrcweir */ 98cdf0e10cSrcweir void PaintCenter ( 99cdf0e10cSrcweir OutputDevice& rDevice, 100cdf0e10cSrcweir const Rectangle& rBox) const; 101cdf0e10cSrcweir }; 102cdf0e10cSrcweir OffsetBitmap maTopLeft; 103cdf0e10cSrcweir OffsetBitmap maTop; 104cdf0e10cSrcweir OffsetBitmap maTopRight; 105cdf0e10cSrcweir OffsetBitmap maLeft; 106cdf0e10cSrcweir OffsetBitmap maRight; 107cdf0e10cSrcweir OffsetBitmap maBottomLeft; 108cdf0e10cSrcweir OffsetBitmap maBottom; 109cdf0e10cSrcweir OffsetBitmap maBottomRight; 110cdf0e10cSrcweir OffsetBitmap maCenter; 111cdf0e10cSrcweir bool mbIsValid; 112cdf0e10cSrcweir }; 113cdf0e10cSrcweir 114cdf0e10cSrcweir 115cdf0e10cSrcweir } } } // end of namespace sd::slidesorter::view 116cdf0e10cSrcweir 117cdf0e10cSrcweir #endif 118