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