1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: PresenterButton.hxx,v $
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_PRESENTER_BUTTON_HXX
33 #define SDEXT_PRESENTER_PRESENTER_BUTTON_HXX
35 #include "PresenterBitmapContainer.hxx"
36 #include "PresenterTheme.hxx"
37 #include <com/sun/star/awt/Rectangle.hpp>
38 #include <com/sun/star/awt/XWindow.hpp>
39 #include <com/sun/star/awt/XWindowListener.hpp>
40 #include <com/sun/star/awt/XPaintListener.hpp>
41 #include <com/sun/star/awt/XMouseListener.hpp>
42 #include <com/sun/star/awt/XMouseMotionListener.hpp>
43 #include <com/sun/star/rendering/XCanvas.hpp>
44 #include <com/sun/star/rendering/XBitmap.hpp>
45 #include <cppuhelper/basemutex.hxx>
46 #include <cppuhelper/compbase4.hxx>
47 #include <boost/noncopyable.hpp>
48 #include <rtl/ref.hxx>
50 namespace css
= ::com::sun::star
;
52 namespace sdext
{ namespace presenter
{
54 class PresenterController
;
57 typedef ::cppu::WeakComponentImplHelper4
<
58 css::awt::XWindowListener
,
59 css::awt::XPaintListener
,
60 css::awt::XMouseListener
,
61 css::awt::XMouseMotionListener
62 > PresenterButtonInterfaceBase
;
65 /** Button for the presenter screen. It displays a text surrounded by a
69 : private ::boost::noncopyable
,
70 private ::cppu::BaseMutex
,
71 public PresenterButtonInterfaceBase
74 static ::rtl::Reference
<PresenterButton
> Create (
75 const css::uno::Reference
<css::uno::XComponentContext
>& rxComponentContext
,
76 const ::rtl::Reference
<PresenterController
>& rpPresenterController
,
77 const ::boost::shared_ptr
<PresenterTheme
>& rpTheme
,
78 const css::uno::Reference
<css::awt::XWindow
>& rxParentWindow
,
79 const css::uno::Reference
<css::rendering::XCanvas
>& rxParentCanvas
,
80 const ::rtl::OUString
& rsConfigurationName
);
81 ~PresenterButton (void);
83 virtual void SAL_CALL
disposing (void);
85 void SetCenter (const css::geometry::RealPoint2D
& rLocation
);
87 const css::uno::Reference
<css::rendering::XCanvas
>& rxParentCanvas
,
88 const css::uno::Reference
<css::awt::XWindow
>& rxParentWindow
);
89 css::geometry::IntegerSize2D
GetSize (void);
93 virtual void SAL_CALL
windowResized (const css::awt::WindowEvent
& rEvent
)
94 throw (css::uno::RuntimeException
);
96 virtual void SAL_CALL
windowMoved (const css::awt::WindowEvent
& rEvent
)
97 throw (css::uno::RuntimeException
);
99 virtual void SAL_CALL
windowShown (const css::lang::EventObject
& rEvent
)
100 throw (css::uno::RuntimeException
);
102 virtual void SAL_CALL
windowHidden (const css::lang::EventObject
& rEvent
)
103 throw (css::uno::RuntimeException
);
108 virtual void SAL_CALL
windowPaint (const css::awt::PaintEvent
& rEvent
)
109 throw (css::uno::RuntimeException
);
114 virtual void SAL_CALL
mousePressed (const css::awt::MouseEvent
& rEvent
)
115 throw(css::uno::RuntimeException
);
117 virtual void SAL_CALL
mouseReleased (const css::awt::MouseEvent
& rEvent
)
118 throw(css::uno::RuntimeException
);
120 virtual void SAL_CALL
mouseEntered (const css::awt::MouseEvent
& rEvent
)
121 throw(css::uno::RuntimeException
);
123 virtual void SAL_CALL
mouseExited (const css::awt::MouseEvent
& rEvent
)
124 throw(css::uno::RuntimeException
);
127 // XMouseMotionListener
129 virtual void SAL_CALL
mouseMoved (const css::awt::MouseEvent
& rEvent
)
130 throw (css::uno::RuntimeException
);
132 virtual void SAL_CALL
mouseDragged (const css::awt::MouseEvent
& rEvent
)
133 throw (css::uno::RuntimeException
);
136 // lang::XEventListener
137 virtual void SAL_CALL
disposing (const css::lang::EventObject
& rEvent
)
138 throw (css::uno::RuntimeException
);
141 ::rtl::Reference
<PresenterController
> mpPresenterController
;
142 ::boost::shared_ptr
<PresenterTheme
> mpTheme
;
143 css::uno::Reference
<css::awt::XWindow
> mxWindow
;
144 css::uno::Reference
<css::rendering::XCanvas
> mxCanvas
;
145 css::uno::Reference
<css::drawing::XPresenterHelper
> mxPresenterHelper
;
146 const ::rtl::OUString msText
;
147 const PresenterTheme::SharedFontDescriptor mpFont
;
148 const PresenterTheme::SharedFontDescriptor mpMouseOverFont
;
149 const ::rtl::OUString msAction
;
150 css::geometry::RealPoint2D maCenter
;
151 css::geometry::IntegerSize2D maButtonSize
;
152 PresenterBitmapDescriptor::Mode meState
;
153 css::uno::Reference
<css::rendering::XBitmap
> mxNormalBitmap
;
154 css::uno::Reference
<css::rendering::XBitmap
> mxMouseOverBitmap
;
157 const css::uno::Reference
<css::uno::XComponentContext
>& rxComponentContext
,
158 const ::rtl::Reference
<PresenterController
>& rpPresenterController
,
159 const ::boost::shared_ptr
<PresenterTheme
>& rpTheme
,
160 const css::uno::Reference
<css::awt::XWindow
>& rxParentWindow
,
161 const PresenterTheme::SharedFontDescriptor
& rFont
,
162 const PresenterTheme::SharedFontDescriptor
& rMouseOverFont
,
163 const ::rtl::OUString
& rxText
,
164 const ::rtl::OUString
& rxAction
);
166 const css::uno::Reference
<css::rendering::XCanvas
>& rxCanvas
,
167 const css::geometry::IntegerSize2D
& rSize
,
168 const PresenterTheme::SharedFontDescriptor
& rFont
,
169 const PresenterBitmapDescriptor::Mode eMode
,
170 const SharedBitmapDescriptor
& rpLeft
,
171 const SharedBitmapDescriptor
& rpCenter
,
172 const SharedBitmapDescriptor
& rpRight
);
173 css::geometry::IntegerSize2D
CalculateButtonSize (void);
174 void Invalidate (void);
175 css::uno::Reference
<css::rendering::XBitmap
> GetBitmap (
176 const SharedBitmapDescriptor
& mpIcon
,
177 const PresenterBitmapDescriptor::Mode eMode
);
178 void SetupButtonBitmaps (void);
179 static css::uno::Reference
<css::beans::XPropertySet
> GetConfigurationProperties (
180 const css::uno::Reference
<css::uno::XComponentContext
>& rxComponentContext
,
181 const ::rtl::OUString
& rsConfgurationName
);
183 void ThrowIfDisposed (void) const
184 throw (::com::sun::star::lang::DisposedException
);