1*06bcd5d2SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*06bcd5d2SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*06bcd5d2SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*06bcd5d2SAndrew Rist  * distributed with this work for additional information
6*06bcd5d2SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*06bcd5d2SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*06bcd5d2SAndrew Rist  * "License"); you may not use this file except in compliance
9*06bcd5d2SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*06bcd5d2SAndrew Rist  *
11*06bcd5d2SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*06bcd5d2SAndrew Rist  *
13*06bcd5d2SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*06bcd5d2SAndrew Rist  * software distributed under the License is distributed on an
15*06bcd5d2SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*06bcd5d2SAndrew Rist  * KIND, either express or implied.  See the License for the
17*06bcd5d2SAndrew Rist  * specific language governing permissions and limitations
18*06bcd5d2SAndrew Rist  * under the License.
19*06bcd5d2SAndrew Rist  *
20*06bcd5d2SAndrew Rist  *************************************************************/
21*06bcd5d2SAndrew Rist 
22*06bcd5d2SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef SDEXT_PRESENTER_BITMAP_CONTAINER_HXX
25cdf0e10cSrcweir #define SDEXT_PRESENTER_BITMAP_CONTAINER_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
28cdf0e10cSrcweir #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
29cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
30cdf0e10cSrcweir #include <com/sun/star/drawing/XPresenterHelper.hpp>
31cdf0e10cSrcweir #include <com/sun/star/rendering/XBitmap.hpp>
32cdf0e10cSrcweir #include <com/sun/star/rendering/XCanvas.hpp>
33cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp>
34cdf0e10cSrcweir #include <com/sun/star/util/Color.hpp>
35cdf0e10cSrcweir #include <boost/noncopyable.hpp>
36cdf0e10cSrcweir #include <boost/scoped_ptr.hpp>
37cdf0e10cSrcweir #include <map>
38cdf0e10cSrcweir #include <vector>
39cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir namespace css = ::com::sun::star;
42cdf0e10cSrcweir 
43cdf0e10cSrcweir 
44cdf0e10cSrcweir namespace sdext { namespace presenter {
45cdf0e10cSrcweir 
46cdf0e10cSrcweir /** Manage a set of bitmap groups as they are used for buttons: three
47cdf0e10cSrcweir     bitmaps, one for the normal state, one for a mouse over effect and one
48cdf0e10cSrcweir     to show that the button has been pressed.
49cdf0e10cSrcweir     A bitmap group is defined by some entries in the configuration.
50cdf0e10cSrcweir */
51cdf0e10cSrcweir class PresenterBitmapContainer
52cdf0e10cSrcweir     : private ::boost::noncopyable
53cdf0e10cSrcweir {
54cdf0e10cSrcweir public:
55cdf0e10cSrcweir     /** There is one bitmap for the normal state, one for a mouse over effect and one
56cdf0e10cSrcweir         to show that a button has been pressed.
57cdf0e10cSrcweir     */
58cdf0e10cSrcweir     class BitmapDescriptor
59cdf0e10cSrcweir     {
60cdf0e10cSrcweir     public:
61cdf0e10cSrcweir         BitmapDescriptor (void);
62cdf0e10cSrcweir         BitmapDescriptor (const ::boost::shared_ptr<BitmapDescriptor>& rpDefault);
63cdf0e10cSrcweir 
64cdf0e10cSrcweir         enum Mode {Normal, MouseOver, ButtonDown, Disabled, Mask};
65cdf0e10cSrcweir         css::uno::Reference<css::rendering::XBitmap> GetNormalBitmap (void) const;
66cdf0e10cSrcweir         css::uno::Reference<css::rendering::XBitmap> GetBitmap (
67cdf0e10cSrcweir             const Mode eMode,
68cdf0e10cSrcweir             const bool bMissingDefaultsToNormal = true) const;
69cdf0e10cSrcweir         void SetBitmap (
70cdf0e10cSrcweir             const Mode eMode,
71cdf0e10cSrcweir             const css::uno::Reference<css::rendering::XBitmap>& rxBitmap);
72cdf0e10cSrcweir 
73cdf0e10cSrcweir         sal_Int32 mnWidth;
74cdf0e10cSrcweir         sal_Int32 mnHeight;
75cdf0e10cSrcweir         sal_Int32 mnXOffset;
76cdf0e10cSrcweir         sal_Int32 mnYOffset;
77cdf0e10cSrcweir         sal_Int32 mnXHotSpot;
78cdf0e10cSrcweir         sal_Int32 mnYHotSpot;
79cdf0e10cSrcweir         css::util::Color maReplacementColor;
80cdf0e10cSrcweir         enum TexturingMode { Once, Repeat, Stretch };
81cdf0e10cSrcweir         TexturingMode meHorizontalTexturingMode;
82cdf0e10cSrcweir         TexturingMode meVerticalTexturingMode;
83cdf0e10cSrcweir 
84cdf0e10cSrcweir     private:
85cdf0e10cSrcweir         css::uno::Reference<css::rendering::XBitmap> mxNormalBitmap;
86cdf0e10cSrcweir         css::uno::Reference<css::rendering::XBitmap> mxMouseOverBitmap;
87cdf0e10cSrcweir         css::uno::Reference<css::rendering::XBitmap> mxButtonDownBitmap;
88cdf0e10cSrcweir         css::uno::Reference<css::rendering::XBitmap> mxDisabledBitmap;
89cdf0e10cSrcweir         css::uno::Reference<css::rendering::XBitmap> mxMaskBitmap;
90cdf0e10cSrcweir     };
91cdf0e10cSrcweir 
92cdf0e10cSrcweir     /** Create a new bitmap container from a section of the configuration.
93cdf0e10cSrcweir         @param rxComponentContext
94cdf0e10cSrcweir             The component context is used to create new API objects.
95cdf0e10cSrcweir         @param rxCanvas
96cdf0e10cSrcweir             Bitmaps are created specifically for this canvas.
97cdf0e10cSrcweir         @param rsConfigurationBase
98cdf0e10cSrcweir             The name of a configuration node whose sub-tree defines the
99cdf0e10cSrcweir             bitmap sets.
100cdf0e10cSrcweir     */
101cdf0e10cSrcweir     PresenterBitmapContainer (
102cdf0e10cSrcweir         const ::rtl::OUString& rsConfigurationBase,
103cdf0e10cSrcweir         const ::boost::shared_ptr<PresenterBitmapContainer>& rpParentContainer,
104cdf0e10cSrcweir         const css::uno::Reference<css::uno::XComponentContext>& rxComponentContext,
105cdf0e10cSrcweir         const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
106cdf0e10cSrcweir         const ::rtl::OUString& rsBasePath,
107cdf0e10cSrcweir         const css::uno::Reference<css::drawing::XPresenterHelper>& rxPresenterHelper = NULL);
108cdf0e10cSrcweir     PresenterBitmapContainer (
109cdf0e10cSrcweir         const css::uno::Reference<css::container::XNameAccess>& rsRootNode,
110cdf0e10cSrcweir         const ::boost::shared_ptr<PresenterBitmapContainer>& rpParentContainer,
111cdf0e10cSrcweir         const css::uno::Reference<css::uno::XComponentContext>& rxComponentContext,
112cdf0e10cSrcweir         const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
113cdf0e10cSrcweir         const ::rtl::OUString& rsBasePath,
114cdf0e10cSrcweir         const css::uno::Reference<css::drawing::XPresenterHelper>& rxPresenterHelper = NULL);
115cdf0e10cSrcweir     ~PresenterBitmapContainer (void);
116cdf0e10cSrcweir 
117cdf0e10cSrcweir     void Initialize (
118cdf0e10cSrcweir         const css::uno::Reference<css::uno::XComponentContext>& rxComponentContext);
119cdf0e10cSrcweir 
120cdf0e10cSrcweir     /** Return the bitmap set that is associated with the given name.
121cdf0e10cSrcweir     */
122cdf0e10cSrcweir     ::boost::shared_ptr<BitmapDescriptor> GetBitmap (const ::rtl::OUString& rsName) const;
123cdf0e10cSrcweir 
124cdf0e10cSrcweir     static ::boost::shared_ptr<BitmapDescriptor> LoadBitmap (
125cdf0e10cSrcweir         const css::uno::Reference<css::container::XHierarchicalNameAccess>& rxNode,
126cdf0e10cSrcweir         const ::rtl::OUString& rsPathToBitmapNode,
127cdf0e10cSrcweir         const css::uno::Reference<css::drawing::XPresenterHelper>& rxPresenterHelper,
128cdf0e10cSrcweir         const ::rtl::OUString& rsBitmapBasePath,
129cdf0e10cSrcweir         const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
130cdf0e10cSrcweir         const ::boost::shared_ptr<BitmapDescriptor>& rpDefaultBitmap);
131cdf0e10cSrcweir 
132cdf0e10cSrcweir private:
133cdf0e10cSrcweir     ::boost::shared_ptr<PresenterBitmapContainer> mpParentContainer;
134cdf0e10cSrcweir     typedef ::std::map<rtl::OUString, ::boost::shared_ptr<BitmapDescriptor> > BitmapContainer;
135cdf0e10cSrcweir     BitmapContainer maIconContainer;
136cdf0e10cSrcweir     ::rtl::OUString msBasePath;
137cdf0e10cSrcweir     css::uno::Reference<css::rendering::XCanvas> mxCanvas;
138cdf0e10cSrcweir     css::uno::Reference<css::drawing::XPresenterHelper> mxPresenterHelper;
139cdf0e10cSrcweir 
140cdf0e10cSrcweir     void LoadBitmaps (
141cdf0e10cSrcweir         const css::uno::Reference<css::container::XNameAccess>& rsRootNode);
142cdf0e10cSrcweir     void ProcessBitmap (
143cdf0e10cSrcweir         const ::rtl::OUString& rsKey,
144cdf0e10cSrcweir         const css::uno::Reference<css::beans::XPropertySet>& rProperties);
145cdf0e10cSrcweir     static ::boost::shared_ptr<BitmapDescriptor> LoadBitmap (
146cdf0e10cSrcweir         const css::uno::Reference<css::beans::XPropertySet>& rxProperties,
147cdf0e10cSrcweir         const css::uno::Reference<css::drawing::XPresenterHelper>& rxPresenterHelper,
148cdf0e10cSrcweir         const ::rtl::OUString& rsBasePath,
149cdf0e10cSrcweir         const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
150cdf0e10cSrcweir         const ::boost::shared_ptr<PresenterBitmapContainer::BitmapDescriptor>& rpDefault);
151cdf0e10cSrcweir     static BitmapDescriptor::TexturingMode
152cdf0e10cSrcweir         StringToTexturingMode (const ::rtl::OUString& rsTexturingMode);
153cdf0e10cSrcweir };
154cdf0e10cSrcweir 
155cdf0e10cSrcweir 
156cdf0e10cSrcweir typedef PresenterBitmapContainer::BitmapDescriptor PresenterBitmapDescriptor;
157cdf0e10cSrcweir typedef ::boost::shared_ptr<PresenterBitmapContainer::BitmapDescriptor> SharedBitmapDescriptor;
158cdf0e10cSrcweir 
159cdf0e10cSrcweir } } // end of namespace ::sdext::presenter
160cdf0e10cSrcweir 
161cdf0e10cSrcweir #endif
162