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