1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef SDEXT_PRESENTER_PRESENTER_WINDOW_MANAGER_HXX
29*cdf0e10cSrcweir #define SDEXT_PRESENTER_PRESENTER_WINDOW_MANAGER_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "PresenterPaneContainer.hxx"
32*cdf0e10cSrcweir #include "PresenterTheme.hxx"
33*cdf0e10cSrcweir #include <com/sun/star/awt/Point.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/awt/XFocusListener.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/awt/XGraphics.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/awt/XMouseMotionListener.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/awt/XPaintListener.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/awt/XWindowListener.hpp>
40*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
41*cdf0e10cSrcweir #include <com/sun/star/document/XEventListener.hpp>
42*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XPane.hpp>
43*cdf0e10cSrcweir #include <com/sun/star/rendering/XBitmap.hpp>
44*cdf0e10cSrcweir #include <com/sun/star/rendering/XSprite.hpp>
45*cdf0e10cSrcweir #include <com/sun/star/rendering/XSpriteCanvas.hpp>
46*cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp>
47*cdf0e10cSrcweir #include <cppuhelper/basemutex.hxx>
48*cdf0e10cSrcweir #include <cppuhelper/compbase4.hxx>
49*cdf0e10cSrcweir #include <tools/gen.hxx>
50*cdf0e10cSrcweir #include <rtl/ref.hxx>
51*cdf0e10cSrcweir #include <boost/noncopyable.hpp>
52*cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir namespace css = ::com::sun::star;
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir namespace sdext { namespace presenter {
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir class PresenterController;
59*cdf0e10cSrcweir class PresenterPaneBorderPainter;
60*cdf0e10cSrcweir class PresenterTheme;
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir namespace {
63*cdf0e10cSrcweir     typedef ::cppu::WeakComponentImplHelper4<
64*cdf0e10cSrcweir         css::awt::XWindowListener,
65*cdf0e10cSrcweir         css::awt::XPaintListener,
66*cdf0e10cSrcweir         css::awt::XMouseListener,
67*cdf0e10cSrcweir         css::awt::XFocusListener
68*cdf0e10cSrcweir     > PresenterWindowManagerInterfaceBase;
69*cdf0e10cSrcweir }
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir /** A simple manager of the positions of the panes of the presenter screen.
73*cdf0e10cSrcweir     Uses relative coordinates of the four sides of each pane.  Allows panes
74*cdf0e10cSrcweir     to be moved or resized with the mouse.
75*cdf0e10cSrcweir */
76*cdf0e10cSrcweir class PresenterWindowManager
77*cdf0e10cSrcweir     : private ::boost::noncopyable,
78*cdf0e10cSrcweir       protected ::cppu::BaseMutex,
79*cdf0e10cSrcweir       public PresenterWindowManagerInterfaceBase
80*cdf0e10cSrcweir {
81*cdf0e10cSrcweir public:
82*cdf0e10cSrcweir     PresenterWindowManager (
83*cdf0e10cSrcweir         const ::css::uno::Reference<css::uno::XComponentContext>& rxContext,
84*cdf0e10cSrcweir         const ::rtl::Reference<PresenterPaneContainer>& rpPaneContainer,
85*cdf0e10cSrcweir         const ::rtl::Reference<PresenterController>& rpPresenterController);
86*cdf0e10cSrcweir     virtual ~PresenterWindowManager (void);
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir     void SAL_CALL disposing (void);
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir     void SetParentPane (const css::uno::Reference<css::drawing::framework::XPane>& rxPane);
91*cdf0e10cSrcweir     void SetTheme (const ::boost::shared_ptr<PresenterTheme>& rpTheme);
92*cdf0e10cSrcweir     void NotifyPaneCreation (const PresenterPaneContainer::SharedPaneDescriptor& rpDescriptor);
93*cdf0e10cSrcweir     void NotifyViewCreation (const css::uno::Reference<css::drawing::framework::XView>& rxView);
94*cdf0e10cSrcweir     void SetPanePosSizeRelative (
95*cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XResourceId>& rxPaneId,
96*cdf0e10cSrcweir         const double nRelativeX,
97*cdf0e10cSrcweir         const double nRelativeY,
98*cdf0e10cSrcweir         const double nRelativeWidth,
99*cdf0e10cSrcweir         const double nRelativeHeight);
100*cdf0e10cSrcweir     void SetPanePosSizeAbsolute (
101*cdf0e10cSrcweir         const ::rtl::OUString& rsPaneURL,
102*cdf0e10cSrcweir         const double nX,
103*cdf0e10cSrcweir         const double nY,
104*cdf0e10cSrcweir         const double nWidth,
105*cdf0e10cSrcweir         const double nHeight);
106*cdf0e10cSrcweir     void SetPaneBorderPainter (const ::rtl::Reference<PresenterPaneBorderPainter>& rPainter);
107*cdf0e10cSrcweir     css::uno::Reference<css::awt::XWindow> GetParentWindow (void) const;
108*cdf0e10cSrcweir     css::uno::Reference<css::rendering::XCanvas> GetParentCanvas (void) const;
109*cdf0e10cSrcweir     void Update (void);
110*cdf0e10cSrcweir     void Layout (void);
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir     void SetSlideSorterState (bool bIsActive);
113*cdf0e10cSrcweir     void SetHelpViewState (bool bIsActive);
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir     enum LayoutMode { LM_Standard, LM_Notes, LM_Generic };
116*cdf0e10cSrcweir private:
117*cdf0e10cSrcweir     void SetLayoutMode (const LayoutMode eMode);
118*cdf0e10cSrcweir     LayoutMode GetLayoutMode (void) const;
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir     bool IsSlideSorterActive (void) const;
121*cdf0e10cSrcweir     bool IsHelpViewActive (void) const;
122*cdf0e10cSrcweir public:
123*cdf0e10cSrcweir     enum ViewMode { VM_Standard, VM_Notes, VM_SlideOverview, VM_Help };
124*cdf0e10cSrcweir     /** The high-level method to switch the view mode.  Use this instead of
125*cdf0e10cSrcweir         SetLayoutMode and Set(Help|SlideSorter)State when possible.
126*cdf0e10cSrcweir     */
127*cdf0e10cSrcweir     void SetViewMode (const ViewMode eMode);
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir     ViewMode GetViewMode (void) const;
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir     /** Restore the layout mode (or slide sorter state) from the
132*cdf0e10cSrcweir         configuration.
133*cdf0e10cSrcweir     */
134*cdf0e10cSrcweir     void RestoreViewMode (void);
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir     void AddLayoutListener (
137*cdf0e10cSrcweir         const css::uno::Reference<css::document::XEventListener>& rxListener);
138*cdf0e10cSrcweir     void RemoveLayoutListener (
139*cdf0e10cSrcweir         const css::uno::Reference<css::document::XEventListener>& rxListener);
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir     // XWindowListener
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir     virtual void SAL_CALL windowResized (const css::awt::WindowEvent& rEvent)
144*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir     virtual void SAL_CALL windowMoved (const css::awt::WindowEvent& rEvent)
147*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir     virtual void SAL_CALL windowShown (const css::lang::EventObject& rEvent)
150*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir     virtual void SAL_CALL windowHidden (const css::lang::EventObject& rEvent)
153*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir     // XPaintListener
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir     virtual void SAL_CALL windowPaint (const css::awt::PaintEvent& rEvent)
159*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir     // XMouseListener
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir     virtual void SAL_CALL mousePressed (const css::awt::MouseEvent& rEvent)
165*cdf0e10cSrcweir         throw(css::uno::RuntimeException);
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir     virtual void SAL_CALL mouseReleased (const css::awt::MouseEvent& rEvent)
168*cdf0e10cSrcweir         throw(css::uno::RuntimeException);
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir     virtual void SAL_CALL mouseEntered (const css::awt::MouseEvent& rEvent)
171*cdf0e10cSrcweir         throw(css::uno::RuntimeException);
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir     virtual void SAL_CALL mouseExited (const css::awt::MouseEvent& rEvent)
174*cdf0e10cSrcweir         throw(css::uno::RuntimeException);
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir     // XFocusListener
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir     virtual void SAL_CALL focusGained (const css::awt::FocusEvent& rEvent)
180*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir     virtual void SAL_CALL focusLost (const css::awt::FocusEvent& rEvent)
183*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir     // XEventListener
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir     virtual void SAL_CALL disposing (
189*cdf0e10cSrcweir         const com::sun::star::lang::EventObject& rEvent)
190*cdf0e10cSrcweir         throw (com::sun::star::uno::RuntimeException);
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir private:
193*cdf0e10cSrcweir     css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
194*cdf0e10cSrcweir     ::rtl::Reference<PresenterController> mpPresenterController;
195*cdf0e10cSrcweir     css::uno::Reference<css::awt::XWindow> mxParentWindow;
196*cdf0e10cSrcweir     css::uno::Reference<css::rendering::XCanvas> mxParentCanvas;
197*cdf0e10cSrcweir     css::uno::Reference<css::uno::XInterface> mxPaneBorderManager;
198*cdf0e10cSrcweir     ::rtl::Reference<PresenterPaneBorderPainter> mpPaneBorderPainter;
199*cdf0e10cSrcweir     ::rtl::Reference<PresenterPaneContainer> mpPaneContainer;
200*cdf0e10cSrcweir     bool mbIsLayoutPending;
201*cdf0e10cSrcweir     /** This flag is set to <TRUE/> while the Layout() method is being
202*cdf0e10cSrcweir         executed.  Prevents windowMoved() and windowResized() from changing
203*cdf0e10cSrcweir         the window sizes.
204*cdf0e10cSrcweir     */
205*cdf0e10cSrcweir     bool mbIsLayouting;
206*cdf0e10cSrcweir     ::boost::shared_ptr<PresenterTheme> mpTheme;
207*cdf0e10cSrcweir     SharedBitmapDescriptor mpBackgroundBitmap;
208*cdf0e10cSrcweir     css::uno::Reference<css::rendering::XBitmap> mxScaledBackgroundBitmap;
209*cdf0e10cSrcweir     css::util::Color maPaneBackgroundColor;
210*cdf0e10cSrcweir     css::uno::Reference<css::rendering::XPolyPolygon2D> mxClipPolygon;
211*cdf0e10cSrcweir     LayoutMode meLayoutMode;
212*cdf0e10cSrcweir     bool mbIsSlideSorterActive;
213*cdf0e10cSrcweir     bool mbIsHelpViewActive;
214*cdf0e10cSrcweir     typedef ::std::vector<css::uno::Reference<css::document::XEventListener> >
215*cdf0e10cSrcweir         LayoutListenerContainer;
216*cdf0e10cSrcweir     LayoutListenerContainer maLayoutListeners;
217*cdf0e10cSrcweir     bool mbIsMouseClickPending;
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir     bool PaintChildren (const css::awt::PaintEvent& rEvent) const;
220*cdf0e10cSrcweir     void UpdateWindowSize (const css::uno::Reference<css::awt::XWindow>& rxBorderWindow);
221*cdf0e10cSrcweir     void PaintBackground (const css::awt::Rectangle& rUpdateBox);
222*cdf0e10cSrcweir     void ProvideBackgroundBitmap (void);
223*cdf0e10cSrcweir     css::uno::Reference<css::rendering::XPolyPolygon2D> CreateClipPolyPolygon (void) const;
224*cdf0e10cSrcweir     void ToTop ();
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir     void UpdateWindowList (void);
227*cdf0e10cSrcweir     bool ChildNeedsRepaint (
228*cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XPane>& rxPane) const;
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir     void Invalidate (void);
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir     void StoreViewMode (const ViewMode eViewMode);
233*cdf0e10cSrcweir 
234*cdf0e10cSrcweir     void LayoutStandardMode (void);
235*cdf0e10cSrcweir     void LayoutNotesMode (void);
236*cdf0e10cSrcweir     void LayoutUnknownMode (void);
237*cdf0e10cSrcweir     void LayoutSlideSorterMode (void);
238*cdf0e10cSrcweir     void LayoutHelpMode (void);
239*cdf0e10cSrcweir 
240*cdf0e10cSrcweir     /** Layout the tool bar and return its outer bounding box.
241*cdf0e10cSrcweir     */
242*cdf0e10cSrcweir     css::geometry::RealRectangle2D LayoutToolBar (void);
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir     css::awt::Size CalculatePaneSize (
245*cdf0e10cSrcweir         const double nOuterWidth,
246*cdf0e10cSrcweir         const ::rtl::OUString& rsPaneURL);
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir     /** Notify changes of the layout mode and of the slide sorter state.
249*cdf0e10cSrcweir     */
250*cdf0e10cSrcweir     void NotifyLayoutModeChange (void);
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir     void NotifyDisposing (void);
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir     void ThrowIfDisposed (void) const throw (::com::sun::star::lang::DisposedException);
255*cdf0e10cSrcweir };
256*cdf0e10cSrcweir 
257*cdf0e10cSrcweir } }
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir #endif
260