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