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 #include "PresenterPane.hxx"
21 #include "PresenterController.hxx"
22 #include "PresenterPaintManager.hxx"
23 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
25 using namespace ::com::sun::star
;
26 using namespace ::com::sun::star::uno
;
27 using namespace ::com::sun::star::drawing::framework
;
29 namespace sdext::presenter
{
31 //===== PresenterPane =========================================================
33 PresenterPane::PresenterPane (
34 const Reference
<XComponentContext
>& rxContext
,
35 const ::rtl::Reference
<PresenterController
>& rpPresenterController
)
36 : PresenterPaneBase(rxContext
, rpPresenterController
)
38 Reference
<lang::XMultiComponentFactory
> xFactory (
39 mxComponentContext
->getServiceManager(), UNO_SET_THROW
);
40 mxPresenterHelper
.set(
41 xFactory
->createInstanceWithContext(
42 "com.sun.star.comp.Draw.PresenterHelper",
47 PresenterPane::~PresenterPane()
51 //----- XPane -----------------------------------------------------------------
53 Reference
<awt::XWindow
> SAL_CALL
PresenterPane::getWindow()
56 return mxContentWindow
;
59 Reference
<rendering::XCanvas
> SAL_CALL
PresenterPane::getCanvas()
62 return mxContentCanvas
;
65 //----- XWindowListener -------------------------------------------------------
67 void SAL_CALL
PresenterPane::windowResized (const awt::WindowEvent
& rEvent
)
69 PresenterPaneBase::windowResized(rEvent
);
71 Invalidate(maBoundingBox
);
73 LayoutContextWindow();
77 Invalidate(maBoundingBox
);
80 void SAL_CALL
PresenterPane::windowMoved (const awt::WindowEvent
& rEvent
)
82 PresenterPaneBase::windowMoved(rEvent
);
84 Invalidate(maBoundingBox
);
89 Invalidate(maBoundingBox
);
92 void SAL_CALL
PresenterPane::windowShown (const lang::EventObject
& rEvent
)
94 PresenterPaneBase::windowShown(rEvent
);
98 if (mxContentWindow
.is())
100 LayoutContextWindow();
101 mxContentWindow
->setVisible(true);
105 Invalidate(maBoundingBox
);
108 void SAL_CALL
PresenterPane::windowHidden (const lang::EventObject
& rEvent
)
110 PresenterPaneBase::windowHidden(rEvent
);
112 if (mxContentWindow
.is())
113 mxContentWindow
->setVisible(false);
116 //----- XPaintListener --------------------------------------------------------
118 void SAL_CALL
PresenterPane::windowPaint (const awt::PaintEvent
& rEvent
)
122 PaintBorder(rEvent
.UpdateRect
);
126 void PresenterPane::CreateCanvases (
127 const Reference
<rendering::XSpriteCanvas
>& rxParentCanvas
)
129 if ( ! mxPresenterHelper
.is())
131 if ( ! mxParentWindow
.is())
133 if ( ! rxParentCanvas
.is())
136 mxBorderCanvas
= mxPresenterHelper
->createSharedCanvas(
142 mxContentCanvas
= mxPresenterHelper
->createSharedCanvas(
149 PaintBorder(mxBorderWindow
->getPosSize());
152 void PresenterPane::Invalidate (const css::awt::Rectangle
& rRepaintBox
)
154 // Invalidate the parent window to be able to invalidate an area outside
155 // the current window area.
156 mpPresenterController
->GetPaintManager()->Invalidate(mxParentWindow
, rRepaintBox
);
159 void PresenterPane::UpdateBoundingBox()
161 if (mxBorderWindow
.is() && IsVisible())
162 maBoundingBox
= mxBorderWindow
->getPosSize();
164 maBoundingBox
= awt::Rectangle();
167 } // end of namespace ::sdext::presenter
169 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */