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 "PresenterPaintManager.hxx"
22 #include "PresenterPaneContainer.hxx"
23 #include <com/sun/star/awt/InvalidateStyle.hpp>
24 #include <com/sun/star/awt/XWindowPeer.hpp>
26 using namespace ::com::sun::star
;
27 using namespace ::com::sun::star::uno
;
29 namespace sdext::presenter
{
31 PresenterPaintManager::PresenterPaintManager (
32 const css::uno::Reference
<css::awt::XWindow
>& rxParentWindow
,
33 const css::uno::Reference
<css::drawing::XPresenterHelper
>& rxPresenterHelper
,
34 const rtl::Reference
<PresenterPaneContainer
>& rpPaneContainer
)
35 : mxParentWindow(rxParentWindow
),
36 mxParentWindowPeer(rxParentWindow
, UNO_QUERY
),
37 mxPresenterHelper(rxPresenterHelper
),
38 mpPaneContainer(rpPaneContainer
)
42 ::std::function
<void (const css::awt::Rectangle
& rRepaintBox
)>
43 PresenterPaintManager::GetInvalidator (
44 const css::uno::Reference
<css::awt::XWindow
>& rxWindow
)
46 return [this, rxWindow
] (css::awt::Rectangle
const& rRepaintBox
)
48 return this->Invalidate(rxWindow
, rRepaintBox
/* , bSynchronous=false */);
52 void PresenterPaintManager::Invalidate (
53 const css::uno::Reference
<css::awt::XWindow
>& rxWindow
)
55 sal_Int16
nInvalidateMode (awt::InvalidateStyle::CHILDREN
);
57 PresenterPaneContainer::SharedPaneDescriptor
pDescriptor(
58 mpPaneContainer
->FindContentWindow(rxWindow
));
59 if (!pDescriptor
|| ! pDescriptor
->mbIsOpaque
)
60 nInvalidateMode
|= awt::InvalidateStyle::TRANSPARENT
;
62 nInvalidateMode
|= awt::InvalidateStyle::NOTRANSPARENT
;
64 Invalidate(rxWindow
, nInvalidateMode
);
67 void PresenterPaintManager::Invalidate (
68 const css::uno::Reference
<css::awt::XWindow
>& rxWindow
,
69 const sal_Int16 nInvalidateFlags
)
71 if ((nInvalidateFlags
& awt::InvalidateStyle::TRANSPARENT
) != 0)
73 // Window is transparent and parent window(s) have to be painted as
74 // well. Invalidate the parent explicitly.
75 if (mxPresenterHelper
.is() && mxParentWindowPeer
.is())
77 const awt::Rectangle
aBBox (
78 mxPresenterHelper
->getWindowExtentsRelative(rxWindow
, mxParentWindow
));
79 mxParentWindowPeer
->invalidateRect(aBBox
, nInvalidateFlags
);
84 Reference
<awt::XWindowPeer
> xPeer (rxWindow
, UNO_QUERY
);
86 xPeer
->invalidate(nInvalidateFlags
);
90 void PresenterPaintManager::Invalidate (
91 const css::uno::Reference
<css::awt::XWindow
>& rxWindow
,
92 const css::awt::Rectangle
& rRepaintBox
,
93 const bool bSynchronous
)
95 sal_Int16
nInvalidateMode (awt::InvalidateStyle::CHILDREN
);
97 nInvalidateMode
|= awt::InvalidateStyle::UPDATE
;
99 PresenterPaneContainer::SharedPaneDescriptor
pDescriptor(
100 mpPaneContainer
->FindContentWindow(rxWindow
));
101 if (!pDescriptor
|| ! pDescriptor
->mbIsOpaque
)
102 nInvalidateMode
|= awt::InvalidateStyle::TRANSPARENT
;
104 nInvalidateMode
|= awt::InvalidateStyle::NOTRANSPARENT
;
106 Invalidate(rxWindow
, rRepaintBox
, nInvalidateMode
);
109 void PresenterPaintManager::Invalidate (
110 const css::uno::Reference
<css::awt::XWindow
>& rxWindow
,
111 const css::awt::Rectangle
& rRepaintBox
,
112 const sal_Int16 nInvalidateFlags
)
114 if ((nInvalidateFlags
& awt::InvalidateStyle::TRANSPARENT
) != 0)
116 // Window is transparent and parent window(s) have to be painted as
117 // well. Invalidate the parent explicitly.
118 if (mxPresenterHelper
.is() && mxParentWindowPeer
.is())
120 const awt::Rectangle
aBBox (
121 mxPresenterHelper
->getWindowExtentsRelative(rxWindow
, mxParentWindow
));
122 mxParentWindowPeer
->invalidateRect(
124 rRepaintBox
.X
+ aBBox
.X
,
125 rRepaintBox
.Y
+ aBBox
.Y
,
133 Reference
<awt::XWindowPeer
> xPeer (rxWindow
, UNO_QUERY
);
135 xPeer
->invalidateRect(rRepaintBox
, nInvalidateFlags
);
141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */