xref: /AOO41X/main/sdext/source/presenter/PresenterButton.hxx (revision 06bcd5d2ad5bea957b02aca5287e5203820c7f8c)
1*06bcd5d2SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*06bcd5d2SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*06bcd5d2SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*06bcd5d2SAndrew Rist  * distributed with this work for additional information
6*06bcd5d2SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*06bcd5d2SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*06bcd5d2SAndrew Rist  * "License"); you may not use this file except in compliance
9*06bcd5d2SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*06bcd5d2SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*06bcd5d2SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*06bcd5d2SAndrew Rist  * software distributed under the License is distributed on an
15*06bcd5d2SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*06bcd5d2SAndrew Rist  * KIND, either express or implied.  See the License for the
17*06bcd5d2SAndrew Rist  * specific language governing permissions and limitations
18*06bcd5d2SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*06bcd5d2SAndrew Rist  *************************************************************/
21*06bcd5d2SAndrew Rist 
22*06bcd5d2SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef SDEXT_PRESENTER_PRESENTER_BUTTON_HXX
25cdf0e10cSrcweir #define SDEXT_PRESENTER_PRESENTER_BUTTON_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "PresenterBitmapContainer.hxx"
28cdf0e10cSrcweir #include "PresenterTheme.hxx"
29cdf0e10cSrcweir #include <com/sun/star/awt/Rectangle.hpp>
30cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp>
31cdf0e10cSrcweir #include <com/sun/star/awt/XWindowListener.hpp>
32cdf0e10cSrcweir #include <com/sun/star/awt/XPaintListener.hpp>
33cdf0e10cSrcweir #include <com/sun/star/awt/XMouseListener.hpp>
34cdf0e10cSrcweir #include <com/sun/star/awt/XMouseMotionListener.hpp>
35cdf0e10cSrcweir #include <com/sun/star/rendering/XCanvas.hpp>
36cdf0e10cSrcweir #include <com/sun/star/rendering/XBitmap.hpp>
37cdf0e10cSrcweir #include <cppuhelper/basemutex.hxx>
38cdf0e10cSrcweir #include <cppuhelper/compbase4.hxx>
39cdf0e10cSrcweir #include <boost/noncopyable.hpp>
40cdf0e10cSrcweir #include <rtl/ref.hxx>
41cdf0e10cSrcweir 
42cdf0e10cSrcweir namespace css = ::com::sun::star;
43cdf0e10cSrcweir 
44cdf0e10cSrcweir namespace sdext { namespace presenter {
45cdf0e10cSrcweir 
46cdf0e10cSrcweir class PresenterController;
47cdf0e10cSrcweir 
48cdf0e10cSrcweir namespace {
49cdf0e10cSrcweir     typedef ::cppu::WeakComponentImplHelper4 <
50cdf0e10cSrcweir         css::awt::XWindowListener,
51cdf0e10cSrcweir         css::awt::XPaintListener,
52cdf0e10cSrcweir         css::awt::XMouseListener,
53cdf0e10cSrcweir         css::awt::XMouseMotionListener
54cdf0e10cSrcweir     > PresenterButtonInterfaceBase;
55cdf0e10cSrcweir }
56cdf0e10cSrcweir 
57cdf0e10cSrcweir /** Button for the presenter screen.  It displays a text surrounded by a
58cdf0e10cSrcweir     frame.
59cdf0e10cSrcweir */
60cdf0e10cSrcweir class PresenterButton
61cdf0e10cSrcweir     : private ::boost::noncopyable,
62cdf0e10cSrcweir       private ::cppu::BaseMutex,
63cdf0e10cSrcweir       public PresenterButtonInterfaceBase
64cdf0e10cSrcweir {
65cdf0e10cSrcweir public:
66cdf0e10cSrcweir     static ::rtl::Reference<PresenterButton> Create (
67cdf0e10cSrcweir         const css::uno::Reference<css::uno::XComponentContext>& rxComponentContext,
68cdf0e10cSrcweir         const ::rtl::Reference<PresenterController>& rpPresenterController,
69cdf0e10cSrcweir         const ::boost::shared_ptr<PresenterTheme>& rpTheme,
70cdf0e10cSrcweir         const css::uno::Reference<css::awt::XWindow>& rxParentWindow,
71cdf0e10cSrcweir         const css::uno::Reference<css::rendering::XCanvas>& rxParentCanvas,
72cdf0e10cSrcweir         const ::rtl::OUString& rsConfigurationName);
73cdf0e10cSrcweir     ~PresenterButton (void);
74cdf0e10cSrcweir 
75cdf0e10cSrcweir     virtual void SAL_CALL disposing (void);
76cdf0e10cSrcweir 
77cdf0e10cSrcweir     void SetCenter (const css::geometry::RealPoint2D& rLocation);
78cdf0e10cSrcweir     void SetCanvas (
79cdf0e10cSrcweir         const css::uno::Reference<css::rendering::XCanvas>& rxParentCanvas,
80cdf0e10cSrcweir         const css::uno::Reference<css::awt::XWindow>& rxParentWindow);
81cdf0e10cSrcweir     css::geometry::IntegerSize2D GetSize (void);
82cdf0e10cSrcweir 
83cdf0e10cSrcweir     // XWindowListener
84cdf0e10cSrcweir 
85cdf0e10cSrcweir     virtual void SAL_CALL windowResized (const css::awt::WindowEvent& rEvent)
86cdf0e10cSrcweir         throw (css::uno::RuntimeException);
87cdf0e10cSrcweir 
88cdf0e10cSrcweir     virtual void SAL_CALL windowMoved (const css::awt::WindowEvent& rEvent)
89cdf0e10cSrcweir         throw (css::uno::RuntimeException);
90cdf0e10cSrcweir 
91cdf0e10cSrcweir     virtual void SAL_CALL windowShown (const css::lang::EventObject& rEvent)
92cdf0e10cSrcweir         throw (css::uno::RuntimeException);
93cdf0e10cSrcweir 
94cdf0e10cSrcweir     virtual void SAL_CALL windowHidden (const css::lang::EventObject& rEvent)
95cdf0e10cSrcweir         throw (css::uno::RuntimeException);
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 
98cdf0e10cSrcweir     // XPaintListener
99cdf0e10cSrcweir 
100cdf0e10cSrcweir     virtual void SAL_CALL windowPaint (const css::awt::PaintEvent& rEvent)
101cdf0e10cSrcweir         throw (css::uno::RuntimeException);
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 
104cdf0e10cSrcweir     // XMouseListener
105cdf0e10cSrcweir 
106cdf0e10cSrcweir     virtual void SAL_CALL mousePressed (const css::awt::MouseEvent& rEvent)
107cdf0e10cSrcweir         throw(css::uno::RuntimeException);
108cdf0e10cSrcweir 
109cdf0e10cSrcweir     virtual void SAL_CALL mouseReleased (const css::awt::MouseEvent& rEvent)
110cdf0e10cSrcweir         throw(css::uno::RuntimeException);
111cdf0e10cSrcweir 
112cdf0e10cSrcweir     virtual void SAL_CALL mouseEntered (const css::awt::MouseEvent& rEvent)
113cdf0e10cSrcweir         throw(css::uno::RuntimeException);
114cdf0e10cSrcweir 
115cdf0e10cSrcweir     virtual void SAL_CALL mouseExited (const css::awt::MouseEvent& rEvent)
116cdf0e10cSrcweir         throw(css::uno::RuntimeException);
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 
119cdf0e10cSrcweir     // XMouseMotionListener
120cdf0e10cSrcweir 
121cdf0e10cSrcweir     virtual void SAL_CALL mouseMoved (const css::awt::MouseEvent& rEvent)
122cdf0e10cSrcweir         throw (css::uno::RuntimeException);
123cdf0e10cSrcweir 
124cdf0e10cSrcweir     virtual void SAL_CALL mouseDragged (const css::awt::MouseEvent& rEvent)
125cdf0e10cSrcweir         throw (css::uno::RuntimeException);
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 
128cdf0e10cSrcweir     // lang::XEventListener
129cdf0e10cSrcweir     virtual void SAL_CALL disposing (const css::lang::EventObject& rEvent)
130cdf0e10cSrcweir         throw (css::uno::RuntimeException);
131cdf0e10cSrcweir 
132cdf0e10cSrcweir private:
133cdf0e10cSrcweir     ::rtl::Reference<PresenterController> mpPresenterController;
134cdf0e10cSrcweir     ::boost::shared_ptr<PresenterTheme> mpTheme;
135cdf0e10cSrcweir     css::uno::Reference<css::awt::XWindow> mxWindow;
136cdf0e10cSrcweir     css::uno::Reference<css::rendering::XCanvas> mxCanvas;
137cdf0e10cSrcweir     css::uno::Reference<css::drawing::XPresenterHelper> mxPresenterHelper;
138cdf0e10cSrcweir     const ::rtl::OUString msText;
139cdf0e10cSrcweir     const PresenterTheme::SharedFontDescriptor mpFont;
140cdf0e10cSrcweir     const PresenterTheme::SharedFontDescriptor mpMouseOverFont;
141cdf0e10cSrcweir     const ::rtl::OUString msAction;
142cdf0e10cSrcweir     css::geometry::RealPoint2D maCenter;
143cdf0e10cSrcweir     css::geometry::IntegerSize2D maButtonSize;
144cdf0e10cSrcweir     PresenterBitmapDescriptor::Mode meState;
145cdf0e10cSrcweir     css::uno::Reference<css::rendering::XBitmap> mxNormalBitmap;
146cdf0e10cSrcweir     css::uno::Reference<css::rendering::XBitmap> mxMouseOverBitmap;
147cdf0e10cSrcweir 
148cdf0e10cSrcweir     PresenterButton (
149cdf0e10cSrcweir         const css::uno::Reference<css::uno::XComponentContext>& rxComponentContext,
150cdf0e10cSrcweir         const ::rtl::Reference<PresenterController>& rpPresenterController,
151cdf0e10cSrcweir         const ::boost::shared_ptr<PresenterTheme>& rpTheme,
152cdf0e10cSrcweir         const css::uno::Reference<css::awt::XWindow>& rxParentWindow,
153cdf0e10cSrcweir         const PresenterTheme::SharedFontDescriptor& rFont,
154cdf0e10cSrcweir         const PresenterTheme::SharedFontDescriptor& rMouseOverFont,
155cdf0e10cSrcweir         const ::rtl::OUString& rxText,
156cdf0e10cSrcweir         const ::rtl::OUString& rxAction);
157cdf0e10cSrcweir     void RenderButton (
158cdf0e10cSrcweir         const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
159cdf0e10cSrcweir         const css::geometry::IntegerSize2D& rSize,
160cdf0e10cSrcweir         const PresenterTheme::SharedFontDescriptor& rFont,
161cdf0e10cSrcweir         const PresenterBitmapDescriptor::Mode eMode,
162cdf0e10cSrcweir         const SharedBitmapDescriptor& rpLeft,
163cdf0e10cSrcweir         const SharedBitmapDescriptor& rpCenter,
164cdf0e10cSrcweir         const SharedBitmapDescriptor& rpRight);
165cdf0e10cSrcweir     css::geometry::IntegerSize2D CalculateButtonSize (void);
166cdf0e10cSrcweir     void Invalidate (void);
167cdf0e10cSrcweir     css::uno::Reference<css::rendering::XBitmap> GetBitmap (
168cdf0e10cSrcweir         const SharedBitmapDescriptor& mpIcon,
169cdf0e10cSrcweir         const PresenterBitmapDescriptor::Mode eMode);
170cdf0e10cSrcweir     void SetupButtonBitmaps (void);
171cdf0e10cSrcweir     static css::uno::Reference<css::beans::XPropertySet> GetConfigurationProperties (
172cdf0e10cSrcweir         const css::uno::Reference<css::uno::XComponentContext>& rxComponentContext,
173cdf0e10cSrcweir         const ::rtl::OUString& rsConfgurationName);
174cdf0e10cSrcweir 
175cdf0e10cSrcweir     void ThrowIfDisposed (void) const
176cdf0e10cSrcweir         throw (::com::sun::star::lang::DisposedException);
177cdf0e10cSrcweir };
178cdf0e10cSrcweir 
179cdf0e10cSrcweir } }
180cdf0e10cSrcweir 
181cdf0e10cSrcweir #endif
182