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