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