Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sd / source / console / PresenterWindowManager.hxx
blob04d164e35f8aba3d164ee43642d6221b5c41e2dc
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/Size.hpp>
26 #include <com/sun/star/awt/XFocusListener.hpp>
27 #include <com/sun/star/awt/XPaintListener.hpp>
28 #include <com/sun/star/awt/XWindow.hpp>
29 #include <com/sun/star/awt/XWindowListener.hpp>
30 #include <com/sun/star/document/XEventListener.hpp>
31 #include <com/sun/star/drawing/framework/XPane.hpp>
32 #include <com/sun/star/rendering/XBitmap.hpp>
33 #include <com/sun/star/uno/XComponentContext.hpp>
34 #include <cppuhelper/basemutex.hxx>
35 #include <cppuhelper/compbase.hxx>
36 #include <rtl/ref.hxx>
37 #include <memory>
39 namespace sdext::presenter {
41 class PresenterController;
42 class PresenterPaneBorderPainter;
43 class PresenterTheme;
45 typedef ::cppu::WeakComponentImplHelper<
46 css::awt::XWindowListener,
47 css::awt::XPaintListener,
48 css::awt::XMouseListener,
49 css::awt::XFocusListener
50 > PresenterWindowManagerInterfaceBase;
52 /** A simple manager of the positions of the panes of the presenter screen.
53 Uses relative coordinates of the four sides of each pane. Allows panes
54 to be moved or resized with the mouse.
56 class PresenterWindowManager
57 : protected ::cppu::BaseMutex,
58 public PresenterWindowManagerInterfaceBase
60 public:
61 PresenterWindowManager (
62 const css::uno::Reference<css::uno::XComponentContext>& rxContext,
63 ::rtl::Reference<PresenterPaneContainer> pPaneContainer,
64 ::rtl::Reference<PresenterController> pPresenterController);
65 virtual ~PresenterWindowManager() override;
66 PresenterWindowManager(const PresenterWindowManager&) = delete;
67 PresenterWindowManager& operator=(const PresenterWindowManager&) = delete;
69 void SAL_CALL disposing() override;
71 void SetParentPane (const css::uno::Reference<css::drawing::framework::XPane>& rxPane);
72 void SetTheme (const std::shared_ptr<PresenterTheme>& rpTheme);
73 void NotifyViewCreation (const css::uno::Reference<css::drawing::framework::XView>& rxView);
74 void SetPanePosSizeAbsolute (
75 const OUString& rsPaneURL,
76 const double nX,
77 const double nY,
78 const double nWidth,
79 const double nHeight);
80 void SetPaneBorderPainter (const ::rtl::Reference<PresenterPaneBorderPainter>& rPainter);
81 void Update();
82 void Layout();
84 void SetSlideSorterState (bool bIsActive);
85 void SetHelpViewState (bool bIsActive);
86 void SetPauseState (bool bIsPaused);
88 enum LayoutMode { LM_Standard, LM_Notes, LM_Generic };
89 private:
90 void SetLayoutMode (const LayoutMode eMode);
92 public:
93 enum ViewMode { VM_Standard, VM_Notes, VM_SlideOverview, VM_Help };
94 /** The high-level method to switch the view mode. Use this instead of
95 SetLayoutMode and Set(Help|SlideSorter)State when possible.
97 void SetViewMode (const ViewMode eMode);
99 ViewMode GetViewMode() const;
101 /** Restore the layout mode (or slide sorter state) from the
102 configuration.
104 void RestoreViewMode();
106 void AddLayoutListener (
107 const css::uno::Reference<css::document::XEventListener>& rxListener);
108 void RemoveLayoutListener (
109 const css::uno::Reference<css::document::XEventListener>& rxListener);
111 // XWindowListener
113 virtual void SAL_CALL windowResized (const css::awt::WindowEvent& rEvent) override;
115 virtual void SAL_CALL windowMoved (const css::awt::WindowEvent& rEvent) override;
117 virtual void SAL_CALL windowShown (const css::lang::EventObject& rEvent) override;
119 virtual void SAL_CALL windowHidden (const css::lang::EventObject& rEvent) override;
121 // XPaintListener
123 virtual void SAL_CALL windowPaint (const css::awt::PaintEvent& rEvent) override;
125 // XMouseListener
127 virtual void SAL_CALL mousePressed (const css::awt::MouseEvent& rEvent) override;
129 virtual void SAL_CALL mouseReleased (const css::awt::MouseEvent& rEvent) override;
131 virtual void SAL_CALL mouseEntered (const css::awt::MouseEvent& rEvent) override;
133 virtual void SAL_CALL mouseExited (const css::awt::MouseEvent& rEvent) override;
135 // XFocusListener
137 virtual void SAL_CALL focusGained (const css::awt::FocusEvent& rEvent) override;
139 virtual void SAL_CALL focusLost (const css::awt::FocusEvent& rEvent) override;
141 // XEventListener
143 virtual void SAL_CALL disposing (
144 const css::lang::EventObject& rEvent) override;
146 private:
147 css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
148 ::rtl::Reference<PresenterController> mpPresenterController;
149 css::uno::Reference<css::awt::XWindow> mxParentWindow;
150 css::uno::Reference<css::rendering::XCanvas> mxParentCanvas;
151 css::uno::Reference<css::uno::XInterface> mxPaneBorderManager;
152 ::rtl::Reference<PresenterPaneBorderPainter> mpPaneBorderPainter;
153 ::rtl::Reference<PresenterPaneContainer> mpPaneContainer;
154 bool mbIsLayoutPending;
155 /** This flag is set to <TRUE/> while the Layout() method is being
156 executed. Prevents windowMoved() and windowResized() from changing
157 the window sizes.
159 bool mbIsLayouting;
160 std::shared_ptr<PresenterTheme> mpTheme;
161 SharedBitmapDescriptor mpBackgroundBitmap;
162 css::uno::Reference<css::rendering::XBitmap> mxScaledBackgroundBitmap;
163 css::uno::Reference<css::rendering::XPolyPolygon2D> mxClipPolygon;
164 LayoutMode meLayoutMode;
165 bool mbIsSlideSorterActive;
166 bool mbIsHelpViewActive;
167 bool mbisPaused;
168 typedef ::std::vector<css::uno::Reference<css::document::XEventListener> >
169 LayoutListenerContainer;
170 LayoutListenerContainer maLayoutListeners;
171 bool mbIsMouseClickPending;
173 void PaintChildren (const css::awt::PaintEvent& rEvent) const;
174 void UpdateWindowSize (const css::uno::Reference<css::awt::XWindow>& rxBorderWindow);
175 void PaintBackground (const css::awt::Rectangle& rUpdateBox);
176 void ProvideBackgroundBitmap();
177 css::uno::Reference<css::rendering::XPolyPolygon2D> CreateClipPolyPolygon() const;
179 void StoreViewMode (const ViewMode eViewMode);
181 void LayoutStandardMode();
182 void LayoutNotesMode();
183 void LayoutSlideSorterMode();
184 void LayoutHelpMode();
186 /** Layout the tool bar and return its outer bounding box.
188 css::geometry::RealRectangle2D LayoutToolBar();
190 css::awt::Size CalculatePaneSize (
191 const double nOuterWidth,
192 const OUString& rsPaneURL);
194 /** Notify changes of the layout mode and of the slide sorter state.
196 void NotifyLayoutModeChange();
198 void NotifyDisposing();
200 /// @throws css::lang::DisposedException
201 void ThrowIfDisposed() const;
206 #endif
208 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */