LibreOffice Module sdext (master)  1
PresenterPaintManager.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
21 
23 #include <com/sun/star/awt/InvalidateStyle.hpp>
24 #include <com/sun/star/awt/XWindowPeer.hpp>
25 
26 using namespace ::com::sun::star;
27 using namespace ::com::sun::star::uno;
28 
29 namespace sdext { namespace presenter {
30 
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)
39 {
40 }
41 
42 ::std::function<void (const css::awt::Rectangle& rRepaintBox)>
44  const css::uno::Reference<css::awt::XWindow>& rxWindow)
45 {
46  return [this, rxWindow] (css::awt::Rectangle const& rRepaintBox)
47  {
48  return this->Invalidate(rxWindow, rRepaintBox /* , bSynchronous=false */);
49  };
50 }
51 
53  const css::uno::Reference<css::awt::XWindow>& rxWindow)
54 {
55  sal_Int16 nInvalidateMode (awt::InvalidateStyle::CHILDREN);
56 
58  mpPaneContainer->FindContentWindow(rxWindow));
59  if (pDescriptor.get()==nullptr || ! pDescriptor->mbIsOpaque)
60  nInvalidateMode |= awt::InvalidateStyle::TRANSPARENT;
61  else
62  nInvalidateMode |= awt::InvalidateStyle::NOTRANSPARENT;
63 
64  Invalidate(rxWindow, nInvalidateMode);
65 }
66 
68  const css::uno::Reference<css::awt::XWindow>& rxWindow,
69  const sal_Int16 nInvalidateFlags)
70 {
71  if ((nInvalidateFlags & awt::InvalidateStyle::TRANSPARENT) != 0)
72  {
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())
76  {
77  const awt::Rectangle aBBox (
78  mxPresenterHelper->getWindowExtentsRelative(rxWindow, mxParentWindow));
79  mxParentWindowPeer->invalidateRect(aBBox, nInvalidateFlags);
80  }
81  }
82  else
83  {
84  Reference<awt::XWindowPeer> xPeer (rxWindow, UNO_QUERY);
85  if (xPeer.is())
86  xPeer->invalidate(nInvalidateFlags);
87  }
88 }
89 
91  const css::uno::Reference<css::awt::XWindow>& rxWindow,
92  const css::awt::Rectangle& rRepaintBox,
93  const bool bSynchronous)
94 {
95  sal_Int16 nInvalidateMode (awt::InvalidateStyle::CHILDREN);
96  if (bSynchronous)
97  nInvalidateMode |= awt::InvalidateStyle::UPDATE;
98 
100  mpPaneContainer->FindContentWindow(rxWindow));
101  if (pDescriptor.get()==nullptr || ! pDescriptor->mbIsOpaque)
102  nInvalidateMode |= awt::InvalidateStyle::TRANSPARENT;
103  else
104  nInvalidateMode |= awt::InvalidateStyle::NOTRANSPARENT;
105 
106  Invalidate(rxWindow, rRepaintBox, nInvalidateMode);
107 }
108 
110  const css::uno::Reference<css::awt::XWindow>& rxWindow,
111  const css::awt::Rectangle& rRepaintBox,
112  const sal_Int16 nInvalidateFlags)
113 {
114  if ((nInvalidateFlags & awt::InvalidateStyle::TRANSPARENT) != 0)
115  {
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())
119  {
120  const awt::Rectangle aBBox (
121  mxPresenterHelper->getWindowExtentsRelative(rxWindow, mxParentWindow));
122  mxParentWindowPeer->invalidateRect(
123  awt::Rectangle(
124  rRepaintBox.X + aBBox.X,
125  rRepaintBox.Y + aBBox.Y,
126  rRepaintBox.Width,
127  rRepaintBox.Height),
128  nInvalidateFlags);
129  }
130  }
131  else
132  {
133  Reference<awt::XWindowPeer> xPeer (rxWindow, UNO_QUERY);
134  if (xPeer.is())
135  xPeer->invalidateRect(rRepaintBox, nInvalidateFlags);
136  }
137 }
138 
139 } }
140 
141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
::rtl::Reference< PresenterPaneContainer > mpPaneContainer
Reference< drawing::XPresenterHelper > mxPresenterHelper
css::uno::Reference< css::awt::XWindowPeer > mxParentWindowPeer
void Invalidate(const css::uno::Reference< css::awt::XWindow > &rxWindow)
Request a repaint of the whole window.
css::uno::Reference< css::awt::XWindow > mxParentWindow
::std::function< void(const css::awt::Rectangle &rRepaintBox)> GetInvalidator(const css::uno::Reference< css::awt::XWindow > &rxWindow)
std::shared_ptr< PaneDescriptor > SharedPaneDescriptor
css::uno::Reference< css::drawing::XPresenterHelper > mxPresenterHelper
PresenterPaintManager(const css::uno::Reference< css::awt::XWindow > &rxParentWindow, const css::uno::Reference< css::drawing::XPresenterHelper > &rxPresenterHelper, const rtl::Reference< PresenterPaneContainer > &rpPaneContainer)
Create paint manager with the window that is the top node in the local window hierarchy.