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 SD_SLIDESORTER_PAGE_OBJECT_PAINTER_HEADER
25 #define SD_SLIDESORTER_PAGE_OBJECT_PAINTER_HEADER
26 
27 #include "SlideSorter.hxx"
28 #include "model/SlsPageDescriptor.hxx"
29 #include "view/SlsLayouter.hxx"
30 #include "view/SlsTheme.hxx"
31 #include <boost/scoped_ptr.hpp>
32 
33 namespace sd { namespace slidesorter { namespace cache {
34 class PageCache;
35 } } }
36 
37 namespace sd { namespace slidesorter { namespace view {
38 
39 class ButtonBar;
40 class Layouter;
41 class PageObjectLayouter;
42 class FramePainter;
43 
44 class PageObjectPainter
45 {
46 public:
47     PageObjectPainter (const SlideSorter& rSlideSorter);
48     ~PageObjectPainter (void);
49 
50     void PaintPageObject (
51         OutputDevice& rDevice,
52         const model::SharedPageDescriptor& rpDescriptor);
53 
54     void NotifyResize (const bool bForce = false);
55 
56     /** Called when the theme changes, either because it is replaced with
57         another or because the system colors have changed.  So, even when
58         the given theme is the same object as the one already in use by this
59         painter everything that depends on the theme is updated.
60     */
61     void SetTheme (const ::boost::shared_ptr<view::Theme>& rpTheme);
62 
63     /** Return a preview bitmap for the given page descriptor.  When the
64         page is excluded from the show then the preview is marked
65         accordingly.
66         @rpDescriptor
67             Defines the page for which to return the preview.
68         @pReferenceDevice
69             When not <NULL/> then this reference device is used to created a
70             compatible bitmap.
71         @return
72             The returned bitmap may have a different size then the preview area.
73     */
74     Bitmap GetPreviewBitmap (
75         const model::SharedPageDescriptor& rpDescriptor,
76         const OutputDevice* pReferenceDevice) const;
77 
78 private:
79     const Layouter& mrLayouter;
80     ::boost::shared_ptr<PageObjectLayouter> mpPageObjectLayouter;
81     ::boost::shared_ptr<cache::PageCache> mpCache;
82     ::boost::shared_ptr<controller::Properties> mpProperties;
83     ::boost::shared_ptr<view::Theme> mpTheme;
84     ::boost::shared_ptr<Font> mpPageNumberFont;
85     ::boost::scoped_ptr<FramePainter> mpShadowPainter;
86     ::boost::scoped_ptr<FramePainter> mpFocusBorderPainter;
87     Bitmap maNormalBackground;
88     Bitmap maSelectionBackground;
89     Bitmap maFocusedSelectionBackground;
90     Bitmap maFocusedBackground;
91     Bitmap maMouseOverBackground;
92     Bitmap maMouseOverFocusedBackground;
93     Bitmap maMouseOverSelectedAndFocusedBackground;
94     ::rtl::OUString msUnhideString;
95     ButtonBar& mrButtonBar;
96     Size maSize;
97 
98     void PaintBackground (
99         OutputDevice& rDevice,
100         const model::SharedPageDescriptor& rpDescriptor);
101     void PaintPreview (
102         OutputDevice& rDevice,
103         const model::SharedPageDescriptor& rpDescriptor) const;
104     void PaintPageNumber (
105         OutputDevice& rDevice,
106         const model::SharedPageDescriptor& rpDescriptor) const;
107     void PaintTransitionEffect (
108         OutputDevice& rDevice,
109         const model::SharedPageDescriptor& rpDescriptor) const;
110     void PaintBorder (
111         OutputDevice& rDevice,
112         const Theme::GradientColorType eColorType,
113         const Rectangle& rBox) const;
114     Bitmap& GetBackgroundForState (
115         const model::SharedPageDescriptor& rpDescriptor,
116         const OutputDevice& rTemplateDevice);
117     Bitmap& GetBackground(
118         Bitmap& rBackground,
119         Theme::GradientColorType eType,
120         const OutputDevice& rTemplateDevice,
121         const bool bHasFocusBorder);
122     Bitmap CreateBackgroundBitmap(
123         const OutputDevice& rReferenceDevice,
124         const Theme::GradientColorType eType,
125         const bool bHasFocusBorder) const;
126     Bitmap CreateMarkedPreview(
127         const Size& rSize,
128         const Bitmap& rPreview,
129         const BitmapEx& rOverlay,
130         const OutputDevice* pReferenceDevice) const;
131     void InvalidateBitmaps (void);
132 
133     /** Update the local pointer to the page object layouter to the
134         one owned by the general layouter.
135         Return <TRUE/> when after the call we have a valid page object layouter.
136     */
137     bool UpdatePageObjectLayouter (void);
138 };
139 
140 } } } // end of namespace sd::slidesorter::view
141 
142 #endif
143