vcl: allow for overriding the default PDF rendering resolution
[LibreOffice.git] / sdext / source / presenter / PresenterWindowManager.hxx
blob55ca7adb75535c43b67e74b41ba56be3f1e58fa8
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 { namespace 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 const ::rtl::Reference<PresenterPaneContainer>& rpPaneContainer,
64 const ::rtl::Reference<PresenterController>& rpPresenterController);
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);
87 enum LayoutMode { LM_Standard, LM_Notes, LM_Generic };
88 private:
89 void SetLayoutMode (const LayoutMode eMode);
91 public:
92 enum ViewMode { VM_Standard, VM_Notes, VM_SlideOverview, VM_Help };
93 /** The high-level method to switch the view mode. Use this instead of
94 SetLayoutMode and Set(Help|SlideSorter)State when possible.
96 void SetViewMode (const ViewMode eMode);
98 ViewMode GetViewMode() const;
100 /** Restore the layout mode (or slide sorter state) from the
101 configuration.
103 void RestoreViewMode();
105 void AddLayoutListener (
106 const css::uno::Reference<css::document::XEventListener>& rxListener);
107 void RemoveLayoutListener (
108 const css::uno::Reference<css::document::XEventListener>& rxListener);
110 // XWindowListener
112 virtual void SAL_CALL windowResized (const css::awt::WindowEvent& rEvent) override;
114 virtual void SAL_CALL windowMoved (const css::awt::WindowEvent& rEvent) override;
116 virtual void SAL_CALL windowShown (const css::lang::EventObject& rEvent) override;
118 virtual void SAL_CALL windowHidden (const css::lang::EventObject& rEvent) override;
120 // XPaintListener
122 virtual void SAL_CALL windowPaint (const css::awt::PaintEvent& rEvent) override;
124 // XMouseListener
126 virtual void SAL_CALL mousePressed (const css::awt::MouseEvent& rEvent) override;
128 virtual void SAL_CALL mouseReleased (const css::awt::MouseEvent& rEvent) override;
130 virtual void SAL_CALL mouseEntered (const css::awt::MouseEvent& rEvent) override;
132 virtual void SAL_CALL mouseExited (const css::awt::MouseEvent& rEvent) override;
134 // XFocusListener
136 virtual void SAL_CALL focusGained (const css::awt::FocusEvent& rEvent) override;
138 virtual void SAL_CALL focusLost (const css::awt::FocusEvent& rEvent) override;
140 // XEventListener
142 virtual void SAL_CALL disposing (
143 const css::lang::EventObject& rEvent) override;
145 private:
146 css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
147 ::rtl::Reference<PresenterController> mpPresenterController;
148 css::uno::Reference<css::awt::XWindow> mxParentWindow;
149 css::uno::Reference<css::rendering::XCanvas> mxParentCanvas;
150 css::uno::Reference<css::uno::XInterface> mxPaneBorderManager;
151 ::rtl::Reference<PresenterPaneBorderPainter> mpPaneBorderPainter;
152 ::rtl::Reference<PresenterPaneContainer> mpPaneContainer;
153 bool mbIsLayoutPending;
154 /** This flag is set to <TRUE/> while the Layout() method is being
155 executed. Prevents windowMoved() and windowResized() from changing
156 the window sizes.
158 bool mbIsLayouting;
159 std::shared_ptr<PresenterTheme> mpTheme;
160 SharedBitmapDescriptor mpBackgroundBitmap;
161 css::uno::Reference<css::rendering::XBitmap> mxScaledBackgroundBitmap;
162 css::uno::Reference<css::rendering::XPolyPolygon2D> mxClipPolygon;
163 LayoutMode meLayoutMode;
164 bool mbIsSlideSorterActive;
165 bool mbIsHelpViewActive;
166 typedef ::std::vector<css::uno::Reference<css::document::XEventListener> >
167 LayoutListenerContainer;
168 LayoutListenerContainer maLayoutListeners;
169 bool mbIsMouseClickPending;
171 void PaintChildren (const css::awt::PaintEvent& rEvent) const;
172 void UpdateWindowSize (const css::uno::Reference<css::awt::XWindow>& rxBorderWindow);
173 void PaintBackground (const css::awt::Rectangle& rUpdateBox);
174 void ProvideBackgroundBitmap();
175 css::uno::Reference<css::rendering::XPolyPolygon2D> CreateClipPolyPolygon() const;
177 void StoreViewMode (const ViewMode eViewMode);
179 void LayoutStandardMode();
180 void LayoutNotesMode();
181 void LayoutSlideSorterMode();
182 void LayoutHelpMode();
184 /** Layout the tool bar and return its outer bounding box.
186 css::geometry::RealRectangle2D LayoutToolBar();
188 css::awt::Size CalculatePaneSize (
189 const double nOuterWidth,
190 const OUString& rsPaneURL);
192 /** Notify changes of the layout mode and of the slide sorter state.
194 void NotifyLayoutModeChange();
196 void NotifyDisposing();
198 /// @throws css::lang::DisposedException
199 void ThrowIfDisposed() const;
204 #endif
206 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */