1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef SD_SLIDESORTER_VIEW_FRAME_PAINTER_HXX 29 #define SD_SLIDESORTER_VIEW_FRAME_PAINTER_HXX 30 31 #include <vcl/bitmapex.hxx> 32 33 34 namespace sd { namespace slidesorter { namespace view { 35 36 class FramePainter 37 { 38 public: 39 FramePainter (const BitmapEx& rBitmap); 40 ~FramePainter (void); 41 42 /** Paint a border around the given box by using a set of bitmaps for 43 the corners and sides. 44 */ 45 void PaintFrame (OutputDevice&rDevice, const Rectangle aBox) const; 46 47 /** Special functionality that takes the color from the center 48 bitmap and replaces that color in all bitmaps by the given new 49 color. Alpha values are not modified. 50 @param bClearCenterBitmap 51 When <TRUE/> then the center bitmap is erased. 52 */ 53 void AdaptColor (const Color aNewColor, const bool bClearCenterBitmap); 54 55 private: 56 /** Bitmap with offset that is used when the bitmap is painted. The bitmap 57 */ 58 class OffsetBitmap { 59 public: 60 BitmapEx maBitmap; 61 Point maOffset; 62 63 /** Create one of the eight shadow bitmaps from one that combines 64 them all. This larger bitmap is expected to have dimension NxN 65 with N=1+2*M. Of this larger bitmap there are created four 66 corner bitmaps of size 2*M x 2*M and four side bitmaps of sizes 67 1xM (top and bottom) and Mx1 (left and right). The corner 68 bitmaps have each one quadrant of size MxM that is painted under 69 the interior of the frame. 70 @param rBitmap 71 The larger bitmap of which the eight shadow bitmaps are cut 72 out from. 73 @param nHorizontalPosition 74 Valid values are -1 (left), 0 (center), and +1 (right). 75 @param nVerticalPosition 76 Valid values are -1 (top), 0 (center), and +1 (bottom). 77 */ 78 OffsetBitmap ( 79 const BitmapEx& rBitmap, 80 const sal_Int32 nHorizontalPosition, 81 const sal_Int32 nVerticalPosition); 82 83 /** Use the given device to paint the bitmap at the location that is 84 the sum of the given anchor and the internal offset. 85 */ 86 void PaintCorner (OutputDevice& rDevice, const Point& rAnchor) const; 87 88 /** Use the given device to paint the bitmap stretched between the 89 two given locations. Offsets of the adjacent corner bitmaps and 90 the offset of the side bitmap are used to determine the area 91 that is to be filled with the side bitmap. 92 */ 93 void PaintSide ( 94 OutputDevice& rDevice, 95 const Point& rAnchor1, 96 const Point& rAnchor2, 97 const OffsetBitmap& rCornerBitmap1, 98 const OffsetBitmap& rCornerBitmap2) const; 99 100 /** Fill the given rectangle with the bitmap. 101 */ 102 void PaintCenter ( 103 OutputDevice& rDevice, 104 const Rectangle& rBox) const; 105 }; 106 OffsetBitmap maTopLeft; 107 OffsetBitmap maTop; 108 OffsetBitmap maTopRight; 109 OffsetBitmap maLeft; 110 OffsetBitmap maRight; 111 OffsetBitmap maBottomLeft; 112 OffsetBitmap maBottom; 113 OffsetBitmap maBottomRight; 114 OffsetBitmap maCenter; 115 bool mbIsValid; 116 }; 117 118 119 } } } // end of namespace sd::slidesorter::view 120 121 #endif 122