update dev300-m58
[ooovba.git] / sdext / source / presenter / PresenterWindowManager.hxx
blobebfe051c930a7896b4827aef63f010ab37d87e19
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: PresenterWindowManager.hxx,v $
11 * $Revision: 1.4 $
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_WINDOW_MANAGER_HXX
33 #define SDEXT_PRESENTER_PRESENTER_WINDOW_MANAGER_HXX
35 #include "PresenterPaneContainer.hxx"
36 #include "PresenterTheme.hxx"
37 #include <com/sun/star/awt/Point.hpp>
38 #include <com/sun/star/awt/XFocusListener.hpp>
39 #include <com/sun/star/awt/XGraphics.hpp>
40 #include <com/sun/star/awt/XMouseMotionListener.hpp>
41 #include <com/sun/star/awt/XPaintListener.hpp>
42 #include <com/sun/star/awt/XWindow.hpp>
43 #include <com/sun/star/awt/XWindowListener.hpp>
44 #include <com/sun/star/beans/XPropertySet.hpp>
45 #include <com/sun/star/document/XEventListener.hpp>
46 #include <com/sun/star/drawing/framework/XPane.hpp>
47 #include <com/sun/star/rendering/XBitmap.hpp>
48 #include <com/sun/star/rendering/XSprite.hpp>
49 #include <com/sun/star/rendering/XSpriteCanvas.hpp>
50 #include <com/sun/star/uno/XComponentContext.hpp>
51 #include <cppuhelper/basemutex.hxx>
52 #include <cppuhelper/compbase4.hxx>
53 #include <tools/gen.hxx>
54 #include <rtl/ref.hxx>
55 #include <boost/noncopyable.hpp>
56 #include <boost/shared_ptr.hpp>
58 namespace css = ::com::sun::star;
60 namespace sdext { namespace presenter {
62 class PresenterController;
63 class PresenterPaneBorderPainter;
64 class PresenterTheme;
66 namespace {
67 typedef ::cppu::WeakComponentImplHelper4<
68 css::awt::XWindowListener,
69 css::awt::XPaintListener,
70 css::awt::XMouseListener,
71 css::awt::XFocusListener
72 > PresenterWindowManagerInterfaceBase;
76 /** A simple manager of the positions of the panes of the presenter screen.
77 Uses relative coordinates of the four sides of each pane. Allows panes
78 to be moved or resized with the mouse.
80 class PresenterWindowManager
81 : private ::boost::noncopyable,
82 protected ::cppu::BaseMutex,
83 public PresenterWindowManagerInterfaceBase
85 public:
86 PresenterWindowManager (
87 const ::css::uno::Reference<css::uno::XComponentContext>& rxContext,
88 const ::rtl::Reference<PresenterPaneContainer>& rpPaneContainer,
89 const ::rtl::Reference<PresenterController>& rpPresenterController);
90 virtual ~PresenterWindowManager (void);
92 void SAL_CALL disposing (void);
94 void SetParentPane (const css::uno::Reference<css::drawing::framework::XPane>& rxPane);
95 void SetTheme (const ::boost::shared_ptr<PresenterTheme>& rpTheme);
96 void NotifyPaneCreation (const PresenterPaneContainer::SharedPaneDescriptor& rpDescriptor);
97 void NotifyViewCreation (const css::uno::Reference<css::drawing::framework::XView>& rxView);
98 void SetPanePosSizeRelative (
99 const css::uno::Reference<css::drawing::framework::XResourceId>& rxPaneId,
100 const double nRelativeX,
101 const double nRelativeY,
102 const double nRelativeWidth,
103 const double nRelativeHeight);
104 void SetPanePosSizeAbsolute (
105 const ::rtl::OUString& rsPaneURL,
106 const double nX,
107 const double nY,
108 const double nWidth,
109 const double nHeight);
110 void SetPaneBorderPainter (const ::rtl::Reference<PresenterPaneBorderPainter>& rPainter);
111 css::uno::Reference<css::awt::XWindow> GetParentWindow (void) const;
112 css::uno::Reference<css::rendering::XCanvas> GetParentCanvas (void) const;
113 void Update (void);
114 void Layout (void);
116 enum LayoutMode { Standard, Notes, Generic };
117 void SetLayoutMode (const LayoutMode eMode);
118 LayoutMode GetLayoutMode (void) const;
120 void SetSlideSorterState (bool bIsActive);
121 bool IsSlideSorterActive (void) const;
123 void SetHelpViewState (bool bIsActive);
124 bool IsHelpViewActive (void) const;
126 void AddLayoutListener (
127 const css::uno::Reference<css::document::XEventListener>& rxListener);
128 void RemoveLayoutListener (
129 const css::uno::Reference<css::document::XEventListener>& rxListener);
131 // XWindowListener
133 virtual void SAL_CALL windowResized (const css::awt::WindowEvent& rEvent)
134 throw (css::uno::RuntimeException);
136 virtual void SAL_CALL windowMoved (const css::awt::WindowEvent& rEvent)
137 throw (css::uno::RuntimeException);
139 virtual void SAL_CALL windowShown (const css::lang::EventObject& rEvent)
140 throw (css::uno::RuntimeException);
142 virtual void SAL_CALL windowHidden (const css::lang::EventObject& rEvent)
143 throw (css::uno::RuntimeException);
146 // XPaintListener
148 virtual void SAL_CALL windowPaint (const css::awt::PaintEvent& rEvent)
149 throw (css::uno::RuntimeException);
152 // XMouseListener
154 virtual void SAL_CALL mousePressed (const css::awt::MouseEvent& rEvent)
155 throw(css::uno::RuntimeException);
157 virtual void SAL_CALL mouseReleased (const css::awt::MouseEvent& rEvent)
158 throw(css::uno::RuntimeException);
160 virtual void SAL_CALL mouseEntered (const css::awt::MouseEvent& rEvent)
161 throw(css::uno::RuntimeException);
163 virtual void SAL_CALL mouseExited (const css::awt::MouseEvent& rEvent)
164 throw(css::uno::RuntimeException);
167 // XFocusListener
169 virtual void SAL_CALL focusGained (const css::awt::FocusEvent& rEvent)
170 throw (css::uno::RuntimeException);
172 virtual void SAL_CALL focusLost (const css::awt::FocusEvent& rEvent)
173 throw (css::uno::RuntimeException);
176 // XEventListener
178 virtual void SAL_CALL disposing (
179 const com::sun::star::lang::EventObject& rEvent)
180 throw (com::sun::star::uno::RuntimeException);
182 private:
183 css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
184 ::rtl::Reference<PresenterController> mpPresenterController;
185 css::uno::Reference<css::awt::XWindow> mxParentWindow;
186 css::uno::Reference<css::rendering::XCanvas> mxParentCanvas;
187 css::uno::Reference<css::uno::XInterface> mxPaneBorderManager;
188 ::rtl::Reference<PresenterPaneBorderPainter> mpPaneBorderPainter;
189 ::rtl::Reference<PresenterPaneContainer> mpPaneContainer;
190 bool mbIsLayoutPending;
191 /** This flag is set to <TRUE/> while the Layout() method is being
192 executed. Prevents windowMoved() and windowResized() from changing
193 the window sizes.
195 bool mbIsLayouting;
196 ::boost::shared_ptr<PresenterTheme> mpTheme;
197 SharedBitmapDescriptor mpBackgroundBitmap;
198 css::uno::Reference<css::rendering::XBitmap> mxScaledBackgroundBitmap;
199 css::util::Color maPaneBackgroundColor;
200 css::uno::Reference<css::rendering::XPolyPolygon2D> mxClipPolygon;
201 LayoutMode meLayoutMode;
202 bool mbIsSlideSorterActive;
203 bool mbIsHelpViewActive;
204 typedef ::std::vector<css::uno::Reference<css::document::XEventListener> >
205 LayoutListenerContainer;
206 LayoutListenerContainer maLayoutListeners;
207 bool mbIsMouseClickPending;
209 bool PaintChildren (const css::awt::PaintEvent& rEvent) const;
210 void UpdateWindowSize (const css::uno::Reference<css::awt::XWindow>& rxBorderWindow);
211 void PaintBackground (const css::awt::Rectangle& rUpdateBox);
212 void ProvideBackgroundBitmap (void);
213 css::uno::Reference<css::rendering::XPolyPolygon2D> CreateClipPolyPolygon (void) const;
214 void ToTop ();
216 void UpdateWindowList (void);
217 bool ChildNeedsRepaint (
218 const css::uno::Reference<css::drawing::framework::XPane>& rxPane) const;
220 void Invalidate (void);
222 void LayoutStandardMode (void);
223 void LayoutNotesMode (void);
224 void LayoutUnknownMode (void);
225 void LayoutSlideSorterMode (void);
226 void LayoutHelpMode (void);
228 /** Layout the tool bar and return its outer bounding box.
230 css::geometry::RealRectangle2D LayoutToolBar (void);
232 css::awt::Size CalculatePaneSize (
233 const double nOuterWidth,
234 const ::rtl::OUString& rsPaneURL);
236 /** Notify changes of the layout mode and of the slide sorter state.
238 void NotifyLayoutModeChange (void);
240 void NotifyDisposing (void);
242 void ThrowIfDisposed (void) const throw (::com::sun::star::lang::DisposedException);
247 #endif