Bump version to 5.0-14
[LibreOffice.git] / sdext / source / presenter / PresenterPaintManager.cxx
blob8c00b7d949dfe71bbfc7fedc1655ad58b6eda914
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 #include "PresenterPaintManager.hxx"
22 #include "PresenterPaneContainer.hxx"
23 #include <com/sun/star/awt/InvalidateStyle.hpp>
24 #include <com/sun/star/awt/XWindowPeer.hpp>
25 #include <boost/bind.hpp>
27 using namespace ::com::sun::star;
28 using namespace ::com::sun::star::uno;
30 namespace sdext { namespace presenter {
32 PresenterPaintManager::PresenterPaintManager (
33 const css::uno::Reference<css::awt::XWindow>& rxParentWindow,
34 const css::uno::Reference<css::drawing::XPresenterHelper>& rxPresenterHelper,
35 const rtl::Reference<PresenterPaneContainer>& rpPaneContainer)
36 : mxParentWindow(rxParentWindow),
37 mxParentWindowPeer(rxParentWindow, UNO_QUERY),
38 mxPresenterHelper(rxPresenterHelper),
39 mpPaneContainer(rpPaneContainer)
43 ::boost::function<void(const css::awt::Rectangle& rRepaintBox)>
44 PresenterPaintManager::GetInvalidator (
45 const css::uno::Reference<css::awt::XWindow>& rxWindow,
46 const bool bSynchronous)
48 return ::boost::bind(
49 static_cast<void (PresenterPaintManager::*)(
50 const css::uno::Reference<css::awt::XWindow>&,
51 const css::awt::Rectangle&,
52 const bool)>(&PresenterPaintManager::Invalidate),
53 this,
54 rxWindow,
55 _1,
56 bSynchronous);
59 void PresenterPaintManager::Invalidate (
60 const css::uno::Reference<css::awt::XWindow>& rxWindow,
61 const bool bSynchronous)
63 sal_Int16 nInvalidateMode (awt::InvalidateStyle::CHILDREN);
64 if (bSynchronous)
65 nInvalidateMode |= awt::InvalidateStyle::UPDATE;
67 PresenterPaneContainer::SharedPaneDescriptor pDescriptor(
68 mpPaneContainer->FindContentWindow(rxWindow));
69 if (pDescriptor.get()==NULL || ! pDescriptor->mbIsOpaque)
70 nInvalidateMode |= awt::InvalidateStyle::TRANSPARENT;
71 else
72 nInvalidateMode |= awt::InvalidateStyle::NOTRANSPARENT;
74 Invalidate(rxWindow, nInvalidateMode);
77 void PresenterPaintManager::Invalidate (
78 const css::uno::Reference<css::awt::XWindow>& rxWindow,
79 const sal_Int16 nInvalidateFlags)
81 if ((nInvalidateFlags & awt::InvalidateStyle::TRANSPARENT) != 0)
83 // Window is transparent and parent window(s) have to be painted as
84 // well. Invalidate the parent explicitly.
85 if (mxPresenterHelper.is() && mxParentWindowPeer.is())
87 const awt::Rectangle aBBox (
88 mxPresenterHelper->getWindowExtentsRelative(rxWindow, mxParentWindow));
89 mxParentWindowPeer->invalidateRect(aBBox, nInvalidateFlags);
92 else
94 Reference<awt::XWindowPeer> xPeer (rxWindow, UNO_QUERY);
95 if (xPeer.is())
96 xPeer->invalidate(nInvalidateFlags);
100 void PresenterPaintManager::Invalidate (
101 const css::uno::Reference<css::awt::XWindow>& rxWindow,
102 const css::awt::Rectangle& rRepaintBox,
103 const bool bSynchronous)
105 sal_Int16 nInvalidateMode (awt::InvalidateStyle::CHILDREN);
106 if (bSynchronous)
107 nInvalidateMode |= awt::InvalidateStyle::UPDATE;
109 PresenterPaneContainer::SharedPaneDescriptor pDescriptor(
110 mpPaneContainer->FindContentWindow(rxWindow));
111 if (pDescriptor.get()==NULL || ! pDescriptor->mbIsOpaque)
112 nInvalidateMode |= awt::InvalidateStyle::TRANSPARENT;
113 else
114 nInvalidateMode |= awt::InvalidateStyle::NOTRANSPARENT;
116 Invalidate(rxWindow, rRepaintBox, nInvalidateMode);
119 void PresenterPaintManager::Invalidate (
120 const css::uno::Reference<css::awt::XWindow>& rxWindow,
121 const css::awt::Rectangle& rRepaintBox,
122 const sal_Int16 nInvalidateFlags)
124 if ((nInvalidateFlags & awt::InvalidateStyle::TRANSPARENT) != 0)
126 // Window is transparent and parent window(s) have to be painted as
127 // well. Invalidate the parent explicitly.
128 if (mxPresenterHelper.is() && mxParentWindowPeer.is())
130 const awt::Rectangle aBBox (
131 mxPresenterHelper->getWindowExtentsRelative(rxWindow, mxParentWindow));
132 mxParentWindowPeer->invalidateRect(
133 awt::Rectangle(
134 rRepaintBox.X + aBBox.X,
135 rRepaintBox.Y + aBBox.Y,
136 rRepaintBox.Width,
137 rRepaintBox.Height),
138 nInvalidateFlags);
141 else
143 Reference<awt::XWindowPeer> xPeer (rxWindow, UNO_QUERY);
144 if (xPeer.is())
145 xPeer->invalidateRect(rRepaintBox, nInvalidateFlags);
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */