1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERBITMAPCONTAINER_HXX
21 #define INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERBITMAPCONTAINER_HXX
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>
34 namespace sdext
{ namespace presenter
{
36 /** Manage a set of bitmap groups as they are used for buttons: three
37 bitmaps, one for the normal state, one for a mouse over effect and one
38 to show that the button has been pressed.
39 A bitmap group is defined by some entries in the configuration.
41 class PresenterBitmapContainer
44 /** There is one bitmap for the normal state, one for a mouse over effect and one
45 to show that a button has been pressed.
47 class BitmapDescriptor
51 explicit BitmapDescriptor (const std::shared_ptr
<BitmapDescriptor
>& rpDefault
);
53 enum Mode
{Normal
, MouseOver
, ButtonDown
, Disabled
, Mask
};
54 const css::uno::Reference
<css::rendering::XBitmap
>& GetNormalBitmap() const;
55 css::uno::Reference
<css::rendering::XBitmap
> const & GetBitmap(const Mode eMode
) const;
58 const css::uno::Reference
<css::rendering::XBitmap
>& rxBitmap
);
66 css::util::Color maReplacementColor
;
67 enum TexturingMode
{ Once
, Repeat
, Stretch
};
68 TexturingMode meHorizontalTexturingMode
;
69 TexturingMode meVerticalTexturingMode
;
72 css::uno::Reference
<css::rendering::XBitmap
> mxNormalBitmap
;
73 css::uno::Reference
<css::rendering::XBitmap
> mxMouseOverBitmap
;
74 css::uno::Reference
<css::rendering::XBitmap
> mxButtonDownBitmap
;
75 css::uno::Reference
<css::rendering::XBitmap
> mxDisabledBitmap
;
76 css::uno::Reference
<css::rendering::XBitmap
> mxMaskBitmap
;
79 /** Create a new bitmap container from a section of the configuration.
80 @param rxComponentContext
81 The component context is used to create new API objects.
83 Bitmaps are created specifically for this canvas.
84 @param rsConfigurationBase
85 The name of a configuration node whose sub-tree defines the
88 PresenterBitmapContainer (
89 const OUString
& rsConfigurationBase
,
90 const std::shared_ptr
<PresenterBitmapContainer
>& rpParentContainer
,
91 const css::uno::Reference
<css::uno::XComponentContext
>& rxComponentContext
,
92 const css::uno::Reference
<css::rendering::XCanvas
>& rxCanvas
,
93 const css::uno::Reference
<css::drawing::XPresenterHelper
>& rxPresenterHelper
= nullptr);
94 PresenterBitmapContainer (
95 const css::uno::Reference
<css::container::XNameAccess
>& rsRootNode
,
96 const std::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
= nullptr);
100 ~PresenterBitmapContainer();
101 PresenterBitmapContainer(const PresenterBitmapContainer
&) = delete;
102 PresenterBitmapContainer
& operator=(const PresenterBitmapContainer
&) = delete;
105 const css::uno::Reference
<css::uno::XComponentContext
>& rxComponentContext
);
107 /** Return the bitmap set that is associated with the given name.
109 std::shared_ptr
<BitmapDescriptor
> GetBitmap (const OUString
& rsName
) const;
111 static std::shared_ptr
<BitmapDescriptor
> LoadBitmap (
112 const css::uno::Reference
<css::container::XHierarchicalNameAccess
>& rxNode
,
113 const OUString
& rsPathToBitmapNode
,
114 const css::uno::Reference
<css::drawing::XPresenterHelper
>& rxPresenterHelper
,
115 const css::uno::Reference
<css::rendering::XCanvas
>& rxCanvas
,
116 const std::shared_ptr
<BitmapDescriptor
>& rpDefaultBitmap
);
119 std::shared_ptr
<PresenterBitmapContainer
> mpParentContainer
;
120 typedef ::std::map
<OUString
, std::shared_ptr
<BitmapDescriptor
> > BitmapContainer
;
121 BitmapContainer maIconContainer
;
122 css::uno::Reference
<css::rendering::XCanvas
> mxCanvas
;
123 css::uno::Reference
<css::drawing::XPresenterHelper
> mxPresenterHelper
;
126 const css::uno::Reference
<css::container::XNameAccess
>& rsRootNode
);
128 const OUString
& rsKey
,
129 const css::uno::Reference
<css::beans::XPropertySet
>& rProperties
);
130 static std::shared_ptr
<BitmapDescriptor
> LoadBitmap (
131 const css::uno::Reference
<css::beans::XPropertySet
>& rxProperties
,
132 const css::uno::Reference
<css::drawing::XPresenterHelper
>& rxPresenterHelper
,
133 const css::uno::Reference
<css::rendering::XCanvas
>& rxCanvas
,
134 const std::shared_ptr
<PresenterBitmapContainer::BitmapDescriptor
>& rpDefault
);
135 static BitmapDescriptor::TexturingMode
136 StringToTexturingMode (const OUString
& rsTexturingMode
);
139 typedef PresenterBitmapContainer::BitmapDescriptor PresenterBitmapDescriptor
;
140 typedef std::shared_ptr
<PresenterBitmapContainer::BitmapDescriptor
> SharedBitmapDescriptor
;
142 } } // end of namespace ::sdext::presenter
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */