Updated core
[LibreOffice.git] / sdext / source / presenter / PresenterToolBar.hxx
blobedbd55a5f979b82711f132f2a1fa10dbe54b6a10
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 SDEXT_PRESENTER_TOOL_BAR_HXX
21 #define SDEXT_PRESENTER_TOOL_BAR_HXX
23 #include "PresenterController.hxx"
24 #include "PresenterViewFactory.hxx"
26 #include <cppuhelper/basemutex.hxx>
27 #include <cppuhelper/compbase3.hxx>
28 #include <cppuhelper/compbase5.hxx>
29 #include <com/sun/star/awt/ActionEvent.hpp>
30 #include <com/sun/star/awt/XActionListener.hpp>
31 #include <com/sun/star/awt/XButton.hpp>
32 #include <com/sun/star/awt/XControl.hpp>
33 #include <com/sun/star/awt/XControlContainer.hpp>
34 #include <com/sun/star/awt/XFixedText.hpp>
35 #include <com/sun/star/awt/XMouseListener.hpp>
36 #include <com/sun/star/awt/XMouseMotionListener.hpp>
37 #include <com/sun/star/awt/XPaintListener.hpp>
38 #include <com/sun/star/awt/XWindowListener.hpp>
39 #include <com/sun/star/container/XNameAccess.hpp>
40 #include <com/sun/star/drawing/XDrawPage.hpp>
41 #include <com/sun/star/drawing/XDrawView.hpp>
42 #include <com/sun/star/drawing/XPresenterHelper.hpp>
43 #include <com/sun/star/drawing/framework/XView.hpp>
44 #include <com/sun/star/drawing/framework/XResourceId.hpp>
45 #include <com/sun/star/frame/XController.hpp>
46 #include <map>
47 #include <boost/scoped_ptr.hpp>
48 #include <boost/function.hpp>
49 #include <boost/noncopyable.hpp>
51 namespace {
52 typedef cppu::WeakComponentImplHelper5<
53 css::awt::XWindowListener,
54 css::awt::XPaintListener,
55 css::awt::XMouseListener,
56 css::awt::XMouseMotionListener,
57 css::drawing::XDrawView
58 > PresenterToolBarInterfaceBase;
60 typedef cppu::WeakComponentImplHelper3<
61 css::awt::XPaintListener,
62 css::drawing::framework::XView,
63 css::drawing::XDrawView
64 > PresenterToolBarViewInterfaceBase;
67 namespace sdext { namespace presenter {
69 /** A simple tool bar that can display bitmapped buttons and labels. At the
70 moment there are buttons for moving to the next and previous slide and
71 to the next effect. A label displayes the index of the current slide
72 and the total number of slides.
74 class PresenterToolBar
75 : private ::cppu::BaseMutex,
76 private ::boost::noncopyable,
77 public PresenterToolBarInterfaceBase,
78 public CachablePresenterView
80 public:
81 typedef ::boost::function<void(void)> Action;
83 enum Anchor { Left, Center, Right };
85 PresenterToolBar (
86 const css::uno::Reference<css::uno::XComponentContext>& rxContext,
87 const css::uno::Reference<css::awt::XWindow>& rxWindow,
88 const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
89 const ::rtl::Reference<PresenterController>& rpPresenterController,
90 const Anchor eAnchor);
91 virtual ~PresenterToolBar (void);
93 void Initialize (
94 const OUString& rsConfigurationPath);
96 virtual void SAL_CALL disposing (void);
98 void InvalidateArea (
99 const css::awt::Rectangle& rRepaintBox,
100 const bool bSynchronous);
102 void RequestLayout (void);
103 css::geometry::RealSize2D GetMinimalSize (void);
104 ::rtl::Reference<PresenterController> GetPresenterController (void) const;
105 css::uno::Reference<css::uno::XComponentContext> GetComponentContext (void) const;
107 // lang::XEventListener
109 virtual void SAL_CALL
110 disposing (const css::lang::EventObject& rEventObject)
111 throw (css::uno::RuntimeException);
113 // XWindowListener
115 virtual void SAL_CALL windowResized (const css::awt::WindowEvent& rEvent)
116 throw (css::uno::RuntimeException);
118 virtual void SAL_CALL windowMoved (const css::awt::WindowEvent& rEvent)
119 throw (css::uno::RuntimeException);
121 virtual void SAL_CALL windowShown (const css::lang::EventObject& rEvent)
122 throw (css::uno::RuntimeException);
124 virtual void SAL_CALL windowHidden (const css::lang::EventObject& rEvent)
125 throw (css::uno::RuntimeException);
127 // XPaintListener
129 virtual void SAL_CALL windowPaint (const css::awt::PaintEvent& rEvent)
130 throw (css::uno::RuntimeException);
132 // XMouseListener
134 virtual void SAL_CALL mousePressed (const css::awt::MouseEvent& rEvent)
135 throw (css::uno::RuntimeException);
137 virtual void SAL_CALL mouseReleased (const css::awt::MouseEvent& rEvent)
138 throw (css::uno::RuntimeException);
140 virtual void SAL_CALL mouseEntered (const css::awt::MouseEvent& rEvent)
141 throw (css::uno::RuntimeException);
143 virtual void SAL_CALL mouseExited (const css::awt::MouseEvent& rEvent)
144 throw (css::uno::RuntimeException);
146 // XMouseMotionListener
148 virtual void SAL_CALL mouseMoved (const css::awt::MouseEvent& rEvent)
149 throw (css::uno::RuntimeException);
151 virtual void SAL_CALL mouseDragged (const css::awt::MouseEvent& rEvent)
152 throw (css::uno::RuntimeException);
154 // XDrawView
156 virtual void SAL_CALL setCurrentPage (
157 const css::uno::Reference<css::drawing::XDrawPage>& rxSlide)
158 throw (css::uno::RuntimeException);
160 virtual css::uno::Reference<css::drawing::XDrawPage> SAL_CALL getCurrentPage (void)
161 throw (css::uno::RuntimeException);
163 class Context;
165 private:
166 css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
168 class ElementContainerPart;
169 typedef ::boost::shared_ptr<ElementContainerPart> SharedElementContainerPart;
170 typedef ::std::vector<SharedElementContainerPart> ElementContainer;
171 ElementContainer maElementContainer;
172 SharedElementContainerPart mpCurrentContainerPart;
173 css::uno::Reference<css::awt::XWindow> mxWindow;
174 css::uno::Reference<css::rendering::XCanvas> mxCanvas;
175 css::uno::Reference<css::presentation::XSlideShowController> mxSlideShowController;
176 css::uno::Reference<css::drawing::XDrawPage> mxCurrentSlide;
177 ::rtl::Reference<PresenterController> mpPresenterController;
178 bool mbIsLayoutPending;
179 const Anchor meAnchor;
180 css::geometry::RealRectangle2D maBoundingBox;
181 /** The minimal size that is necessary to display all elements without
182 overlap and with minimal gaps between them.
184 css::geometry::RealSize2D maMinimalSize;
186 void CreateControls (
187 const OUString& rsConfigurationPath);
188 void Layout (const css::uno::Reference<css::rendering::XCanvas>& rxCanvas);
189 css::geometry::RealSize2D CalculatePartSize (
190 const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
191 const SharedElementContainerPart& rpPart,
192 const bool bIsHorizontal);
193 void LayoutPart (
194 const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
195 const SharedElementContainerPart& rpPart,
196 const css::geometry::RealRectangle2D& rBoundingBox,
197 const css::geometry::RealSize2D& rPartSize,
198 const bool bIsHorizontal);
199 void Clear (
200 const css::awt::Rectangle& rUpdateBox,
201 const css::rendering::ViewState& rViewState);
202 void Paint (
203 const css::awt::Rectangle& rUpdateBox,
204 const css::rendering::ViewState& rViewState);
206 void UpdateSlideNumber (void);
208 void CheckMouseOver (
209 const css::awt::MouseEvent& rEvent,
210 const bool bOverWindow,
211 const bool bMouseDown=false);
213 void ProcessEntry (
214 const css::uno::Reference<css::beans::XPropertySet>& rProperties,
215 Context& rContext);
217 /** This method throws a DisposedException when the object has already been
218 disposed.
220 void ThrowIfDisposed (void) const
221 throw (css::lang::DisposedException);
224 /** View for the PresenterToolBar.
226 class PresenterToolBarView
227 : private ::cppu::BaseMutex,
228 private ::boost::noncopyable,
229 public PresenterToolBarViewInterfaceBase
231 public:
232 explicit PresenterToolBarView (
233 const css::uno::Reference<css::uno::XComponentContext>& rxContext,
234 const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId,
235 const css::uno::Reference<css::frame::XController>& rxController,
236 const ::rtl::Reference<PresenterController>& rpPresenterController);
237 virtual ~PresenterToolBarView (void);
239 virtual void SAL_CALL disposing (void);
241 ::rtl::Reference<PresenterToolBar> GetPresenterToolBar (void) const;
243 // XPaintListener
245 virtual void SAL_CALL windowPaint (const css::awt::PaintEvent& rEvent)
246 throw (css::uno::RuntimeException);
248 // lang::XEventListener
250 virtual void SAL_CALL
251 disposing (const css::lang::EventObject& rEventObject)
252 throw (css::uno::RuntimeException);
254 // XResourceId
256 virtual css::uno::Reference<css::drawing::framework::XResourceId> SAL_CALL getResourceId (void)
257 throw (css::uno::RuntimeException);
259 virtual sal_Bool SAL_CALL isAnchorOnly (void)
260 throw (com::sun::star::uno::RuntimeException);
262 // XDrawView
264 virtual void SAL_CALL setCurrentPage (
265 const css::uno::Reference<css::drawing::XDrawPage>& rxSlide)
266 throw (css::uno::RuntimeException);
268 virtual css::uno::Reference<css::drawing::XDrawPage> SAL_CALL getCurrentPage (void)
269 throw (css::uno::RuntimeException);
271 private:
272 // css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
273 css::uno::Reference<css::drawing::framework::XPane> mxPane;
274 css::uno::Reference<css::drawing::framework::XResourceId> mxViewId;
275 css::uno::Reference<css::awt::XWindow> mxWindow;
276 css::uno::Reference<css::rendering::XCanvas> mxCanvas;
277 ::rtl::Reference<PresenterController> mpPresenterController;
278 css::uno::Reference<css::presentation::XSlideShowController> mxSlideShowController;
279 ::rtl::Reference<PresenterToolBar> mpToolBar;
283 } } // end of namespace ::sdext::presenter
285 #endif
287 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */