1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERWINDOWMANAGER_HXX
21 #define INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERWINDOWMANAGER_HXX
23 #include "PresenterPaneContainer.hxx"
24 #include "PresenterTheme.hxx"
25 #include <com/sun/star/awt/Point.hpp>
26 #include <com/sun/star/awt/XFocusListener.hpp>
27 #include <com/sun/star/awt/XGraphics.hpp>
28 #include <com/sun/star/awt/XMouseMotionListener.hpp>
29 #include <com/sun/star/awt/XPaintListener.hpp>
30 #include <com/sun/star/awt/XWindow.hpp>
31 #include <com/sun/star/awt/XWindowListener.hpp>
32 #include <com/sun/star/beans/XPropertySet.hpp>
33 #include <com/sun/star/document/XEventListener.hpp>
34 #include <com/sun/star/drawing/framework/XPane.hpp>
35 #include <com/sun/star/rendering/XBitmap.hpp>
36 #include <com/sun/star/rendering/XSprite.hpp>
37 #include <com/sun/star/rendering/XSpriteCanvas.hpp>
38 #include <com/sun/star/uno/XComponentContext.hpp>
39 #include <cppuhelper/basemutex.hxx>
40 #include <cppuhelper/compbase4.hxx>
41 #include <rtl/ref.hxx>
42 #include <boost/noncopyable.hpp>
43 #include <boost/shared_ptr.hpp>
45 namespace sdext
{ namespace presenter
{
47 class PresenterController
;
48 class PresenterPaneBorderPainter
;
52 typedef ::cppu::WeakComponentImplHelper4
<
53 css::awt::XWindowListener
,
54 css::awt::XPaintListener
,
55 css::awt::XMouseListener
,
56 css::awt::XFocusListener
57 > PresenterWindowManagerInterfaceBase
;
60 /** A simple manager of the positions of the panes of the presenter screen.
61 Uses relative coordinates of the four sides of each pane. Allows panes
62 to be moved or resized with the mouse.
64 class PresenterWindowManager
65 : private ::boost::noncopyable
,
66 protected ::cppu::BaseMutex
,
67 public PresenterWindowManagerInterfaceBase
70 PresenterWindowManager (
71 const css::uno::Reference
<css::uno::XComponentContext
>& rxContext
,
72 const ::rtl::Reference
<PresenterPaneContainer
>& rpPaneContainer
,
73 const ::rtl::Reference
<PresenterController
>& rpPresenterController
);
74 virtual ~PresenterWindowManager();
76 void SAL_CALL
disposing() SAL_OVERRIDE
;
78 void SetParentPane (const css::uno::Reference
<css::drawing::framework::XPane
>& rxPane
);
79 void SetTheme (const ::boost::shared_ptr
<PresenterTheme
>& rpTheme
);
80 void NotifyViewCreation (const css::uno::Reference
<css::drawing::framework::XView
>& rxView
);
81 void SetPanePosSizeAbsolute (
82 const OUString
& rsPaneURL
,
86 const double nHeight
);
87 void SetPaneBorderPainter (const ::rtl::Reference
<PresenterPaneBorderPainter
>& rPainter
);
91 void SetSlideSorterState (bool bIsActive
);
92 void SetHelpViewState (bool bIsActive
);
94 enum LayoutMode
{ LM_Standard
, LM_Notes
, LM_Generic
};
96 void SetLayoutMode (const LayoutMode eMode
);
99 enum ViewMode
{ VM_Standard
, VM_Notes
, VM_SlideOverview
, VM_Help
};
100 /** The high-level method to switch the view mode. Use this instead of
101 SetLayoutMode and Set(Help|SlideSorter)State when possible.
103 void SetViewMode (const ViewMode eMode
);
105 ViewMode
GetViewMode() const;
107 /** Restore the layout mode (or slide sorter state) from the
110 void RestoreViewMode();
112 void AddLayoutListener (
113 const css::uno::Reference
<css::document::XEventListener
>& rxListener
);
114 void RemoveLayoutListener (
115 const css::uno::Reference
<css::document::XEventListener
>& rxListener
);
119 virtual void SAL_CALL
windowResized (const css::awt::WindowEvent
& rEvent
)
120 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
122 virtual void SAL_CALL
windowMoved (const css::awt::WindowEvent
& rEvent
)
123 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
125 virtual void SAL_CALL
windowShown (const css::lang::EventObject
& rEvent
)
126 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
128 virtual void SAL_CALL
windowHidden (const css::lang::EventObject
& rEvent
)
129 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
133 virtual void SAL_CALL
windowPaint (const css::awt::PaintEvent
& rEvent
)
134 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
138 virtual void SAL_CALL
mousePressed (const css::awt::MouseEvent
& rEvent
)
139 throw(css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
141 virtual void SAL_CALL
mouseReleased (const css::awt::MouseEvent
& rEvent
)
142 throw(css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
144 virtual void SAL_CALL
mouseEntered (const css::awt::MouseEvent
& rEvent
)
145 throw(css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
147 virtual void SAL_CALL
mouseExited (const css::awt::MouseEvent
& rEvent
)
148 throw(css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
152 virtual void SAL_CALL
focusGained (const css::awt::FocusEvent
& rEvent
)
153 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
155 virtual void SAL_CALL
focusLost (const css::awt::FocusEvent
& rEvent
)
156 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
160 virtual void SAL_CALL
disposing (
161 const css::lang::EventObject
& rEvent
)
162 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
165 css::uno::Reference
<css::uno::XComponentContext
> mxComponentContext
;
166 ::rtl::Reference
<PresenterController
> mpPresenterController
;
167 css::uno::Reference
<css::awt::XWindow
> mxParentWindow
;
168 css::uno::Reference
<css::rendering::XCanvas
> mxParentCanvas
;
169 css::uno::Reference
<css::uno::XInterface
> mxPaneBorderManager
;
170 ::rtl::Reference
<PresenterPaneBorderPainter
> mpPaneBorderPainter
;
171 ::rtl::Reference
<PresenterPaneContainer
> mpPaneContainer
;
172 bool mbIsLayoutPending
;
173 /** This flag is set to <TRUE/> while the Layout() method is being
174 executed. Prevents windowMoved() and windowResized() from changing
178 ::boost::shared_ptr
<PresenterTheme
> mpTheme
;
179 SharedBitmapDescriptor mpBackgroundBitmap
;
180 css::uno::Reference
<css::rendering::XBitmap
> mxScaledBackgroundBitmap
;
181 css::util::Color maPaneBackgroundColor
;
182 css::uno::Reference
<css::rendering::XPolyPolygon2D
> mxClipPolygon
;
183 LayoutMode meLayoutMode
;
184 bool mbIsSlideSorterActive
;
185 bool mbIsHelpViewActive
;
186 typedef ::std::vector
<css::uno::Reference
<css::document::XEventListener
> >
187 LayoutListenerContainer
;
188 LayoutListenerContainer maLayoutListeners
;
189 bool mbIsMouseClickPending
;
191 bool PaintChildren (const css::awt::PaintEvent
& rEvent
) const;
192 void UpdateWindowSize (const css::uno::Reference
<css::awt::XWindow
>& rxBorderWindow
);
193 void PaintBackground (const css::awt::Rectangle
& rUpdateBox
);
194 void ProvideBackgroundBitmap();
195 css::uno::Reference
<css::rendering::XPolyPolygon2D
> CreateClipPolyPolygon() const;
198 static void UpdateWindowList();
199 bool ChildNeedsRepaint (
200 const css::uno::Reference
<css::drawing::framework::XPane
>& rxPane
) const;
204 void StoreViewMode (const ViewMode eViewMode
);
206 void LayoutStandardMode();
207 void LayoutNotesMode();
208 void LayoutSlideSorterMode();
209 void LayoutHelpMode();
211 /** Layout the tool bar and return its outer bounding box.
213 css::geometry::RealRectangle2D
LayoutToolBar();
215 css::awt::Size
CalculatePaneSize (
216 const double nOuterWidth
,
217 const OUString
& rsPaneURL
);
219 /** Notify changes of the layout mode and of the slide sorter state.
221 void NotifyLayoutModeChange();
223 void NotifyDisposing();
225 void ThrowIfDisposed() const throw (css::lang::DisposedException
);
232 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */