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 SDEXT_PRESENTER_BITMAP_CONTAINER_HXX
21 : #define SDEXT_PRESENTER_BITMAP_CONTAINER_HXX
22 :
23 : #include <com/sun/star/beans/XPropertySet.hpp>
24 : #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
25 : #include <com/sun/star/container/XNameAccess.hpp>
26 : #include <com/sun/star/drawing/XPresenterHelper.hpp>
27 : #include <com/sun/star/rendering/XBitmap.hpp>
28 : #include <com/sun/star/rendering/XCanvas.hpp>
29 : #include <com/sun/star/uno/XComponentContext.hpp>
30 : #include <com/sun/star/util/Color.hpp>
31 : #include <boost/noncopyable.hpp>
32 : #include <boost/scoped_ptr.hpp>
33 : #include <map>
34 : #include <vector>
35 : #include <boost/shared_ptr.hpp>
36 :
37 : namespace sdext { namespace presenter {
38 :
39 : /** Manage a set of bitmap groups as they are used for buttons: three
40 : bitmaps, one for the normal state, one for a mouse over effect and one
41 : to show that the button has been pressed.
42 : A bitmap group is defined by some entries in the configuration.
43 : */
44 : class PresenterBitmapContainer
45 : : private ::boost::noncopyable
46 : {
47 : public:
48 : /** There is one bitmap for the normal state, one for a mouse over effect and one
49 : to show that a button has been pressed.
50 : */
51 0 : class BitmapDescriptor
52 : {
53 : public:
54 : BitmapDescriptor (void);
55 : BitmapDescriptor (const ::boost::shared_ptr<BitmapDescriptor>& rpDefault);
56 :
57 : enum Mode {Normal, MouseOver, ButtonDown, Disabled, Mask};
58 : css::uno::Reference<css::rendering::XBitmap> GetNormalBitmap (void) const;
59 : css::uno::Reference<css::rendering::XBitmap> GetBitmap (
60 : const Mode eMode,
61 : const bool bMissingDefaultsToNormal = true) const;
62 : void SetBitmap (
63 : const Mode eMode,
64 : const css::uno::Reference<css::rendering::XBitmap>& rxBitmap);
65 :
66 : sal_Int32 mnWidth;
67 : sal_Int32 mnHeight;
68 : sal_Int32 mnXOffset;
69 : sal_Int32 mnYOffset;
70 : sal_Int32 mnXHotSpot;
71 : sal_Int32 mnYHotSpot;
72 : css::util::Color maReplacementColor;
73 : enum TexturingMode { Once, Repeat, Stretch };
74 : TexturingMode meHorizontalTexturingMode;
75 : TexturingMode meVerticalTexturingMode;
76 :
77 : private:
78 : css::uno::Reference<css::rendering::XBitmap> mxNormalBitmap;
79 : css::uno::Reference<css::rendering::XBitmap> mxMouseOverBitmap;
80 : css::uno::Reference<css::rendering::XBitmap> mxButtonDownBitmap;
81 : css::uno::Reference<css::rendering::XBitmap> mxDisabledBitmap;
82 : css::uno::Reference<css::rendering::XBitmap> mxMaskBitmap;
83 : };
84 :
85 : /** Create a new bitmap container from a section of the configuration.
86 : @param rxComponentContext
87 : The component context is used to create new API objects.
88 : @param rxCanvas
89 : Bitmaps are created specifically for this canvas.
90 : @param rsConfigurationBase
91 : The name of a configuration node whose sub-tree defines the
92 : bitmap sets.
93 : */
94 : PresenterBitmapContainer (
95 : const ::rtl::OUString& rsConfigurationBase,
96 : const ::boost::shared_ptr<PresenterBitmapContainer>& rpParentContainer,
97 : const css::uno::Reference<css::uno::XComponentContext>& rxComponentContext,
98 : const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
99 : const css::uno::Reference<css::drawing::XPresenterHelper>& rxPresenterHelper = NULL);
100 : PresenterBitmapContainer (
101 : const css::uno::Reference<css::container::XNameAccess>& rsRootNode,
102 : const ::boost::shared_ptr<PresenterBitmapContainer>& rpParentContainer,
103 : const css::uno::Reference<css::uno::XComponentContext>& rxComponentContext,
104 : const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
105 : const css::uno::Reference<css::drawing::XPresenterHelper>& rxPresenterHelper = NULL);
106 : ~PresenterBitmapContainer (void);
107 :
108 : void Initialize (
109 : const css::uno::Reference<css::uno::XComponentContext>& rxComponentContext);
110 :
111 : /** Return the bitmap set that is associated with the given name.
112 : */
113 : ::boost::shared_ptr<BitmapDescriptor> GetBitmap (const ::rtl::OUString& rsName) const;
114 :
115 : static ::boost::shared_ptr<BitmapDescriptor> LoadBitmap (
116 : const css::uno::Reference<css::container::XHierarchicalNameAccess>& rxNode,
117 : const ::rtl::OUString& rsPathToBitmapNode,
118 : const css::uno::Reference<css::drawing::XPresenterHelper>& rxPresenterHelper,
119 : const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
120 : const ::boost::shared_ptr<BitmapDescriptor>& rpDefaultBitmap);
121 :
122 : private:
123 : ::boost::shared_ptr<PresenterBitmapContainer> mpParentContainer;
124 : typedef ::std::map<rtl::OUString, ::boost::shared_ptr<BitmapDescriptor> > BitmapContainer;
125 : BitmapContainer maIconContainer;
126 : css::uno::Reference<css::rendering::XCanvas> mxCanvas;
127 : css::uno::Reference<css::drawing::XPresenterHelper> mxPresenterHelper;
128 :
129 : void LoadBitmaps (
130 : const css::uno::Reference<css::container::XNameAccess>& rsRootNode);
131 : void ProcessBitmap (
132 : const ::rtl::OUString& rsKey,
133 : const css::uno::Reference<css::beans::XPropertySet>& rProperties);
134 : static ::boost::shared_ptr<BitmapDescriptor> LoadBitmap (
135 : const css::uno::Reference<css::beans::XPropertySet>& rxProperties,
136 : const css::uno::Reference<css::drawing::XPresenterHelper>& rxPresenterHelper,
137 : const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
138 : const ::boost::shared_ptr<PresenterBitmapContainer::BitmapDescriptor>& rpDefault);
139 : static BitmapDescriptor::TexturingMode
140 : StringToTexturingMode (const ::rtl::OUString& rsTexturingMode);
141 : };
142 :
143 : typedef PresenterBitmapContainer::BitmapDescriptor PresenterBitmapDescriptor;
144 : typedef ::boost::shared_ptr<PresenterBitmapContainer::BitmapDescriptor> SharedBitmapDescriptor;
145 :
146 : } } // end of namespace ::sdext::presenter
147 :
148 : #endif
149 :
150 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|