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_PRESENTERBUTTON_HXX
21 #define INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERBUTTON_HXX
23 #include "PresenterBitmapContainer.hxx"
24 #include "PresenterTheme.hxx"
25 #include <com/sun/star/awt/Rectangle.hpp>
26 #include <com/sun/star/awt/XWindow.hpp>
27 #include <com/sun/star/awt/XWindowListener.hpp>
28 #include <com/sun/star/awt/XPaintListener.hpp>
29 #include <com/sun/star/awt/XMouseListener.hpp>
30 #include <com/sun/star/awt/XMouseMotionListener.hpp>
31 #include <com/sun/star/rendering/XCanvas.hpp>
32 #include <com/sun/star/rendering/XBitmap.hpp>
33 #include <cppuhelper/basemutex.hxx>
34 #include <cppuhelper/compbase4.hxx>
35 #include <boost/noncopyable.hpp>
36 #include <rtl/ref.hxx>
38 namespace sdext
{ namespace presenter
{
40 class PresenterController
;
43 typedef ::cppu::WeakComponentImplHelper4
<
44 css::awt::XWindowListener
,
45 css::awt::XPaintListener
,
46 css::awt::XMouseListener
,
47 css::awt::XMouseMotionListener
48 > PresenterButtonInterfaceBase
;
51 /** Button for the presenter screen. It displays a text surrounded by a
55 : private ::boost::noncopyable
,
56 private ::cppu::BaseMutex
,
57 public PresenterButtonInterfaceBase
60 static ::rtl::Reference
<PresenterButton
> Create (
61 const css::uno::Reference
<css::uno::XComponentContext
>& rxComponentContext
,
62 const ::rtl::Reference
<PresenterController
>& rpPresenterController
,
63 const ::boost::shared_ptr
<PresenterTheme
>& rpTheme
,
64 const css::uno::Reference
<css::awt::XWindow
>& rxParentWindow
,
65 const css::uno::Reference
<css::rendering::XCanvas
>& rxParentCanvas
,
66 const OUString
& rsConfigurationName
);
67 virtual ~PresenterButton();
69 virtual void SAL_CALL
disposing() SAL_OVERRIDE
;
71 void SetCenter (const css::geometry::RealPoint2D
& rLocation
);
73 const css::uno::Reference
<css::rendering::XCanvas
>& rxParentCanvas
,
74 const css::uno::Reference
<css::awt::XWindow
>& rxParentWindow
);
75 css::geometry::IntegerSize2D
GetSize();
79 virtual void SAL_CALL
windowResized (const css::awt::WindowEvent
& rEvent
)
80 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
82 virtual void SAL_CALL
windowMoved (const css::awt::WindowEvent
& rEvent
)
83 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
85 virtual void SAL_CALL
windowShown (const css::lang::EventObject
& rEvent
)
86 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
88 virtual void SAL_CALL
windowHidden (const css::lang::EventObject
& rEvent
)
89 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
93 virtual void SAL_CALL
windowPaint (const css::awt::PaintEvent
& rEvent
)
94 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
98 virtual void SAL_CALL
mousePressed (const css::awt::MouseEvent
& rEvent
)
99 throw(css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
101 virtual void SAL_CALL
mouseReleased (const css::awt::MouseEvent
& rEvent
)
102 throw(css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
104 virtual void SAL_CALL
mouseEntered (const css::awt::MouseEvent
& rEvent
)
105 throw(css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
107 virtual void SAL_CALL
mouseExited (const css::awt::MouseEvent
& rEvent
)
108 throw(css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
110 // XMouseMotionListener
112 virtual void SAL_CALL
mouseMoved (const css::awt::MouseEvent
& rEvent
)
113 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
115 virtual void SAL_CALL
mouseDragged (const css::awt::MouseEvent
& rEvent
)
116 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
118 // lang::XEventListener
119 virtual void SAL_CALL
disposing (const css::lang::EventObject
& rEvent
)
120 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
123 ::rtl::Reference
<PresenterController
> mpPresenterController
;
124 ::boost::shared_ptr
<PresenterTheme
> mpTheme
;
125 css::uno::Reference
<css::awt::XWindow
> mxWindow
;
126 css::uno::Reference
<css::rendering::XCanvas
> mxCanvas
;
127 css::uno::Reference
<css::drawing::XPresenterHelper
> mxPresenterHelper
;
128 const OUString msText
;
129 const PresenterTheme::SharedFontDescriptor mpFont
;
130 const PresenterTheme::SharedFontDescriptor mpMouseOverFont
;
131 const OUString msAction
;
132 css::geometry::RealPoint2D maCenter
;
133 css::geometry::IntegerSize2D maButtonSize
;
134 PresenterBitmapDescriptor::Mode meState
;
135 css::uno::Reference
<css::rendering::XBitmap
> mxNormalBitmap
;
136 css::uno::Reference
<css::rendering::XBitmap
> mxMouseOverBitmap
;
139 const css::uno::Reference
<css::uno::XComponentContext
>& rxComponentContext
,
140 const ::rtl::Reference
<PresenterController
>& rpPresenterController
,
141 const ::boost::shared_ptr
<PresenterTheme
>& rpTheme
,
142 const css::uno::Reference
<css::awt::XWindow
>& rxParentWindow
,
143 const PresenterTheme::SharedFontDescriptor
& rFont
,
144 const PresenterTheme::SharedFontDescriptor
& rMouseOverFont
,
145 const OUString
& rxText
,
146 const OUString
& rxAction
);
148 const css::uno::Reference
<css::rendering::XCanvas
>& rxCanvas
,
149 const css::geometry::IntegerSize2D
& rSize
,
150 const PresenterTheme::SharedFontDescriptor
& rFont
,
151 const PresenterBitmapDescriptor::Mode eMode
,
152 const SharedBitmapDescriptor
& rpLeft
,
153 const SharedBitmapDescriptor
& rpCenter
,
154 const SharedBitmapDescriptor
& rpRight
);
155 css::geometry::IntegerSize2D
CalculateButtonSize();
157 static css::uno::Reference
<css::rendering::XBitmap
> GetBitmap (
158 const SharedBitmapDescriptor
& mpIcon
,
159 const PresenterBitmapDescriptor::Mode eMode
);
160 void SetupButtonBitmaps();
161 static css::uno::Reference
<css::beans::XPropertySet
> GetConfigurationProperties (
162 const css::uno::Reference
<css::uno::XComponentContext
>& rxComponentContext
,
163 const OUString
& rsConfgurationName
);
165 void ThrowIfDisposed() const
166 throw (css::lang::DisposedException
);
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */