1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef SDEXT_PRESENTER_BITMAP_CONTAINER_HXX
29*cdf0e10cSrcweir #define SDEXT_PRESENTER_BITMAP_CONTAINER_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
32*cdf0e10cSrcweir #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
33*cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/drawing/XPresenterHelper.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/rendering/XBitmap.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/rendering/XCanvas.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/util/Color.hpp>
39*cdf0e10cSrcweir #include <boost/noncopyable.hpp>
40*cdf0e10cSrcweir #include <boost/scoped_ptr.hpp>
41*cdf0e10cSrcweir #include <map>
42*cdf0e10cSrcweir #include <vector>
43*cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir namespace css = ::com::sun::star;
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir namespace sdext { namespace presenter {
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir /** Manage a set of bitmap groups as they are used for buttons: three
51*cdf0e10cSrcweir     bitmaps, one for the normal state, one for a mouse over effect and one
52*cdf0e10cSrcweir     to show that the button has been pressed.
53*cdf0e10cSrcweir     A bitmap group is defined by some entries in the configuration.
54*cdf0e10cSrcweir */
55*cdf0e10cSrcweir class PresenterBitmapContainer
56*cdf0e10cSrcweir     : private ::boost::noncopyable
57*cdf0e10cSrcweir {
58*cdf0e10cSrcweir public:
59*cdf0e10cSrcweir     /** There is one bitmap for the normal state, one for a mouse over effect and one
60*cdf0e10cSrcweir         to show that a button has been pressed.
61*cdf0e10cSrcweir     */
62*cdf0e10cSrcweir     class BitmapDescriptor
63*cdf0e10cSrcweir     {
64*cdf0e10cSrcweir     public:
65*cdf0e10cSrcweir         BitmapDescriptor (void);
66*cdf0e10cSrcweir         BitmapDescriptor (const ::boost::shared_ptr<BitmapDescriptor>& rpDefault);
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir         enum Mode {Normal, MouseOver, ButtonDown, Disabled, Mask};
69*cdf0e10cSrcweir         css::uno::Reference<css::rendering::XBitmap> GetNormalBitmap (void) const;
70*cdf0e10cSrcweir         css::uno::Reference<css::rendering::XBitmap> GetBitmap (
71*cdf0e10cSrcweir             const Mode eMode,
72*cdf0e10cSrcweir             const bool bMissingDefaultsToNormal = true) const;
73*cdf0e10cSrcweir         void SetBitmap (
74*cdf0e10cSrcweir             const Mode eMode,
75*cdf0e10cSrcweir             const css::uno::Reference<css::rendering::XBitmap>& rxBitmap);
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir         sal_Int32 mnWidth;
78*cdf0e10cSrcweir         sal_Int32 mnHeight;
79*cdf0e10cSrcweir         sal_Int32 mnXOffset;
80*cdf0e10cSrcweir         sal_Int32 mnYOffset;
81*cdf0e10cSrcweir         sal_Int32 mnXHotSpot;
82*cdf0e10cSrcweir         sal_Int32 mnYHotSpot;
83*cdf0e10cSrcweir         css::util::Color maReplacementColor;
84*cdf0e10cSrcweir         enum TexturingMode { Once, Repeat, Stretch };
85*cdf0e10cSrcweir         TexturingMode meHorizontalTexturingMode;
86*cdf0e10cSrcweir         TexturingMode meVerticalTexturingMode;
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir     private:
89*cdf0e10cSrcweir         css::uno::Reference<css::rendering::XBitmap> mxNormalBitmap;
90*cdf0e10cSrcweir         css::uno::Reference<css::rendering::XBitmap> mxMouseOverBitmap;
91*cdf0e10cSrcweir         css::uno::Reference<css::rendering::XBitmap> mxButtonDownBitmap;
92*cdf0e10cSrcweir         css::uno::Reference<css::rendering::XBitmap> mxDisabledBitmap;
93*cdf0e10cSrcweir         css::uno::Reference<css::rendering::XBitmap> mxMaskBitmap;
94*cdf0e10cSrcweir     };
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir     /** Create a new bitmap container from a section of the configuration.
97*cdf0e10cSrcweir         @param rxComponentContext
98*cdf0e10cSrcweir             The component context is used to create new API objects.
99*cdf0e10cSrcweir         @param rxCanvas
100*cdf0e10cSrcweir             Bitmaps are created specifically for this canvas.
101*cdf0e10cSrcweir         @param rsConfigurationBase
102*cdf0e10cSrcweir             The name of a configuration node whose sub-tree defines the
103*cdf0e10cSrcweir             bitmap sets.
104*cdf0e10cSrcweir     */
105*cdf0e10cSrcweir     PresenterBitmapContainer (
106*cdf0e10cSrcweir         const ::rtl::OUString& rsConfigurationBase,
107*cdf0e10cSrcweir         const ::boost::shared_ptr<PresenterBitmapContainer>& rpParentContainer,
108*cdf0e10cSrcweir         const css::uno::Reference<css::uno::XComponentContext>& rxComponentContext,
109*cdf0e10cSrcweir         const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
110*cdf0e10cSrcweir         const ::rtl::OUString& rsBasePath,
111*cdf0e10cSrcweir         const css::uno::Reference<css::drawing::XPresenterHelper>& rxPresenterHelper = NULL);
112*cdf0e10cSrcweir     PresenterBitmapContainer (
113*cdf0e10cSrcweir         const css::uno::Reference<css::container::XNameAccess>& rsRootNode,
114*cdf0e10cSrcweir         const ::boost::shared_ptr<PresenterBitmapContainer>& rpParentContainer,
115*cdf0e10cSrcweir         const css::uno::Reference<css::uno::XComponentContext>& rxComponentContext,
116*cdf0e10cSrcweir         const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
117*cdf0e10cSrcweir         const ::rtl::OUString& rsBasePath,
118*cdf0e10cSrcweir         const css::uno::Reference<css::drawing::XPresenterHelper>& rxPresenterHelper = NULL);
119*cdf0e10cSrcweir     ~PresenterBitmapContainer (void);
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir     void Initialize (
122*cdf0e10cSrcweir         const css::uno::Reference<css::uno::XComponentContext>& rxComponentContext);
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir     /** Return the bitmap set that is associated with the given name.
125*cdf0e10cSrcweir     */
126*cdf0e10cSrcweir     ::boost::shared_ptr<BitmapDescriptor> GetBitmap (const ::rtl::OUString& rsName) const;
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir     static ::boost::shared_ptr<BitmapDescriptor> LoadBitmap (
129*cdf0e10cSrcweir         const css::uno::Reference<css::container::XHierarchicalNameAccess>& rxNode,
130*cdf0e10cSrcweir         const ::rtl::OUString& rsPathToBitmapNode,
131*cdf0e10cSrcweir         const css::uno::Reference<css::drawing::XPresenterHelper>& rxPresenterHelper,
132*cdf0e10cSrcweir         const ::rtl::OUString& rsBitmapBasePath,
133*cdf0e10cSrcweir         const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
134*cdf0e10cSrcweir         const ::boost::shared_ptr<BitmapDescriptor>& rpDefaultBitmap);
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir private:
137*cdf0e10cSrcweir     ::boost::shared_ptr<PresenterBitmapContainer> mpParentContainer;
138*cdf0e10cSrcweir     typedef ::std::map<rtl::OUString, ::boost::shared_ptr<BitmapDescriptor> > BitmapContainer;
139*cdf0e10cSrcweir     BitmapContainer maIconContainer;
140*cdf0e10cSrcweir     ::rtl::OUString msBasePath;
141*cdf0e10cSrcweir     css::uno::Reference<css::rendering::XCanvas> mxCanvas;
142*cdf0e10cSrcweir     css::uno::Reference<css::drawing::XPresenterHelper> mxPresenterHelper;
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir     void LoadBitmaps (
145*cdf0e10cSrcweir         const css::uno::Reference<css::container::XNameAccess>& rsRootNode);
146*cdf0e10cSrcweir     void ProcessBitmap (
147*cdf0e10cSrcweir         const ::rtl::OUString& rsKey,
148*cdf0e10cSrcweir         const css::uno::Reference<css::beans::XPropertySet>& rProperties);
149*cdf0e10cSrcweir     static ::boost::shared_ptr<BitmapDescriptor> LoadBitmap (
150*cdf0e10cSrcweir         const css::uno::Reference<css::beans::XPropertySet>& rxProperties,
151*cdf0e10cSrcweir         const css::uno::Reference<css::drawing::XPresenterHelper>& rxPresenterHelper,
152*cdf0e10cSrcweir         const ::rtl::OUString& rsBasePath,
153*cdf0e10cSrcweir         const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
154*cdf0e10cSrcweir         const ::boost::shared_ptr<PresenterBitmapContainer::BitmapDescriptor>& rpDefault);
155*cdf0e10cSrcweir     static BitmapDescriptor::TexturingMode
156*cdf0e10cSrcweir         StringToTexturingMode (const ::rtl::OUString& rsTexturingMode);
157*cdf0e10cSrcweir };
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir typedef PresenterBitmapContainer::BitmapDescriptor PresenterBitmapDescriptor;
161*cdf0e10cSrcweir typedef ::boost::shared_ptr<PresenterBitmapContainer::BitmapDescriptor> SharedBitmapDescriptor;
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir } } // end of namespace ::sdext::presenter
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir #endif
166