1*c142477cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*c142477cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*c142477cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*c142477cSAndrew Rist  * distributed with this work for additional information
6*c142477cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*c142477cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*c142477cSAndrew Rist  * "License"); you may not use this file except in compliance
9*c142477cSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*c142477cSAndrew Rist  *
11*c142477cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*c142477cSAndrew Rist  *
13*c142477cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*c142477cSAndrew Rist  * software distributed under the License is distributed on an
15*c142477cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*c142477cSAndrew Rist  * KIND, either express or implied.  See the License for the
17*c142477cSAndrew Rist  * specific language governing permissions and limitations
18*c142477cSAndrew Rist  * under the License.
19*c142477cSAndrew Rist  *
20*c142477cSAndrew Rist  *************************************************************/
21*c142477cSAndrew Rist 
22*c142477cSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sdext.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "PresenterPaintManager.hxx"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include "PresenterPaneContainer.hxx"
30cdf0e10cSrcweir #include <com/sun/star/awt/InvalidateStyle.hpp>
31cdf0e10cSrcweir #include <com/sun/star/awt/XWindowPeer.hpp>
32cdf0e10cSrcweir #include <boost/bind.hpp>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir using namespace ::com::sun::star;
35cdf0e10cSrcweir using namespace ::com::sun::star::uno;
36cdf0e10cSrcweir 
37cdf0e10cSrcweir namespace sdext { namespace presenter {
38cdf0e10cSrcweir 
PresenterPaintManager(const css::uno::Reference<css::awt::XWindow> & rxParentWindow,const css::uno::Reference<css::drawing::XPresenterHelper> & rxPresenterHelper,const rtl::Reference<PresenterPaneContainer> & rpPaneContainer)39cdf0e10cSrcweir PresenterPaintManager::PresenterPaintManager (
40cdf0e10cSrcweir     const css::uno::Reference<css::awt::XWindow>& rxParentWindow,
41cdf0e10cSrcweir     const css::uno::Reference<css::drawing::XPresenterHelper>& rxPresenterHelper,
42cdf0e10cSrcweir     const rtl::Reference<PresenterPaneContainer>& rpPaneContainer)
43cdf0e10cSrcweir     : mxParentWindow(rxParentWindow),
44cdf0e10cSrcweir       mxParentWindowPeer(rxParentWindow, UNO_QUERY),
45cdf0e10cSrcweir       mxPresenterHelper(rxPresenterHelper),
46cdf0e10cSrcweir       mpPaneContainer(rpPaneContainer)
47cdf0e10cSrcweir {
48cdf0e10cSrcweir }
49cdf0e10cSrcweir 
50cdf0e10cSrcweir 
51cdf0e10cSrcweir 
52cdf0e10cSrcweir 
53cdf0e10cSrcweir ::boost::function<void(const css::awt::Rectangle& rRepaintBox)>
GetInvalidator(const css::uno::Reference<css::awt::XWindow> & rxWindow,const bool bSynchronous)54cdf0e10cSrcweir     PresenterPaintManager::GetInvalidator (
55cdf0e10cSrcweir         const css::uno::Reference<css::awt::XWindow>& rxWindow,
56cdf0e10cSrcweir         const bool bSynchronous)
57cdf0e10cSrcweir {
58cdf0e10cSrcweir     return ::boost::bind(
59cdf0e10cSrcweir         static_cast<void (PresenterPaintManager::*)(
60cdf0e10cSrcweir             const css::uno::Reference<css::awt::XWindow>&,
61cdf0e10cSrcweir             const css::awt::Rectangle&,
62cdf0e10cSrcweir             const bool)>(&PresenterPaintManager::Invalidate),
63cdf0e10cSrcweir         this,
64cdf0e10cSrcweir         rxWindow,
65cdf0e10cSrcweir         _1,
66cdf0e10cSrcweir         bSynchronous);
67cdf0e10cSrcweir }
68cdf0e10cSrcweir 
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 
71cdf0e10cSrcweir 
Invalidate(const css::uno::Reference<css::awt::XWindow> & rxWindow,const bool bSynchronous)72cdf0e10cSrcweir void PresenterPaintManager::Invalidate (
73cdf0e10cSrcweir     const css::uno::Reference<css::awt::XWindow>& rxWindow,
74cdf0e10cSrcweir     const bool bSynchronous)
75cdf0e10cSrcweir {
76cdf0e10cSrcweir     sal_Int16 nInvalidateMode (awt::InvalidateStyle::CHILDREN);
77cdf0e10cSrcweir     if (bSynchronous)
78cdf0e10cSrcweir         nInvalidateMode |= awt::InvalidateStyle::UPDATE;
79cdf0e10cSrcweir 
80cdf0e10cSrcweir     PresenterPaneContainer::SharedPaneDescriptor pDescriptor(
81cdf0e10cSrcweir         mpPaneContainer->FindContentWindow(rxWindow));
82cdf0e10cSrcweir     if (pDescriptor.get()==NULL || ! pDescriptor->mbIsOpaque)
83cdf0e10cSrcweir         nInvalidateMode |= awt::InvalidateStyle::TRANSPARENT;
84cdf0e10cSrcweir     else
85cdf0e10cSrcweir         nInvalidateMode |= awt::InvalidateStyle::NOTRANSPARENT;
86cdf0e10cSrcweir 
87cdf0e10cSrcweir     Invalidate(rxWindow, nInvalidateMode);
88cdf0e10cSrcweir }
89cdf0e10cSrcweir 
90cdf0e10cSrcweir 
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 
Invalidate(const css::uno::Reference<css::awt::XWindow> & rxWindow,const sal_Int16 nInvalidateFlags)93cdf0e10cSrcweir void PresenterPaintManager::Invalidate (
94cdf0e10cSrcweir     const css::uno::Reference<css::awt::XWindow>& rxWindow,
95cdf0e10cSrcweir     const sal_Int16 nInvalidateFlags)
96cdf0e10cSrcweir {
97cdf0e10cSrcweir     if ((nInvalidateFlags & awt::InvalidateStyle::TRANSPARENT) != 0)
98cdf0e10cSrcweir     {
99cdf0e10cSrcweir         // Window is transparent and parent window(s) have to be painted as
100cdf0e10cSrcweir         // well.  Invalidate the parent explicitly.
101cdf0e10cSrcweir         if (mxPresenterHelper.is() && mxParentWindowPeer.is())
102cdf0e10cSrcweir         {
103cdf0e10cSrcweir             const awt::Rectangle aBBox (
104cdf0e10cSrcweir                 mxPresenterHelper->getWindowExtentsRelative(rxWindow, mxParentWindow));
105cdf0e10cSrcweir             mxParentWindowPeer->invalidateRect(aBBox, nInvalidateFlags);
106cdf0e10cSrcweir         }
107cdf0e10cSrcweir     }
108cdf0e10cSrcweir     else
109cdf0e10cSrcweir     {
110cdf0e10cSrcweir         Reference<awt::XWindowPeer> xPeer (rxWindow, UNO_QUERY);
111cdf0e10cSrcweir         if (xPeer.is())
112cdf0e10cSrcweir             xPeer->invalidate(nInvalidateFlags);
113cdf0e10cSrcweir     }
114cdf0e10cSrcweir }
115cdf0e10cSrcweir 
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 
Invalidate(const css::uno::Reference<css::awt::XWindow> & rxWindow,const css::awt::Rectangle & rRepaintBox,const bool bSynchronous)119cdf0e10cSrcweir void PresenterPaintManager::Invalidate (
120cdf0e10cSrcweir     const css::uno::Reference<css::awt::XWindow>& rxWindow,
121cdf0e10cSrcweir     const css::awt::Rectangle& rRepaintBox,
122cdf0e10cSrcweir     const bool bSynchronous)
123cdf0e10cSrcweir {
124cdf0e10cSrcweir     sal_Int16 nInvalidateMode (awt::InvalidateStyle::CHILDREN);
125cdf0e10cSrcweir     if (bSynchronous)
126cdf0e10cSrcweir         nInvalidateMode |= awt::InvalidateStyle::UPDATE;
127cdf0e10cSrcweir 
128cdf0e10cSrcweir     PresenterPaneContainer::SharedPaneDescriptor pDescriptor(
129cdf0e10cSrcweir         mpPaneContainer->FindContentWindow(rxWindow));
130cdf0e10cSrcweir     if (pDescriptor.get()==NULL || ! pDescriptor->mbIsOpaque)
131cdf0e10cSrcweir         nInvalidateMode |= awt::InvalidateStyle::TRANSPARENT;
132cdf0e10cSrcweir     else
133cdf0e10cSrcweir         nInvalidateMode |= awt::InvalidateStyle::NOTRANSPARENT;
134cdf0e10cSrcweir 
135cdf0e10cSrcweir     Invalidate(rxWindow, rRepaintBox, nInvalidateMode);
136cdf0e10cSrcweir }
137cdf0e10cSrcweir 
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 
140cdf0e10cSrcweir 
Invalidate(const css::uno::Reference<css::awt::XWindow> & rxWindow,const css::awt::Rectangle & rRepaintBox,const sal_Int16 nInvalidateFlags)141cdf0e10cSrcweir void PresenterPaintManager::Invalidate (
142cdf0e10cSrcweir     const css::uno::Reference<css::awt::XWindow>& rxWindow,
143cdf0e10cSrcweir     const css::awt::Rectangle& rRepaintBox,
144cdf0e10cSrcweir     const sal_Int16 nInvalidateFlags)
145cdf0e10cSrcweir {
146cdf0e10cSrcweir     if ((nInvalidateFlags & awt::InvalidateStyle::TRANSPARENT) != 0)
147cdf0e10cSrcweir     {
148cdf0e10cSrcweir         // Window is transparent and parent window(s) have to be painted as
149cdf0e10cSrcweir         // well.  Invalidate the parent explicitly.
150cdf0e10cSrcweir         if (mxPresenterHelper.is() && mxParentWindowPeer.is())
151cdf0e10cSrcweir         {
152cdf0e10cSrcweir             const awt::Rectangle aBBox (
153cdf0e10cSrcweir                 mxPresenterHelper->getWindowExtentsRelative(rxWindow, mxParentWindow));
154cdf0e10cSrcweir             mxParentWindowPeer->invalidateRect(
155cdf0e10cSrcweir                 awt::Rectangle(
156cdf0e10cSrcweir                     rRepaintBox.X + aBBox.X,
157cdf0e10cSrcweir                     rRepaintBox.Y + aBBox.Y,
158cdf0e10cSrcweir                     rRepaintBox.Width,
159cdf0e10cSrcweir                     rRepaintBox.Height),
160cdf0e10cSrcweir                 nInvalidateFlags);
161cdf0e10cSrcweir         }
162cdf0e10cSrcweir     }
163cdf0e10cSrcweir     else
164cdf0e10cSrcweir     {
165cdf0e10cSrcweir         Reference<awt::XWindowPeer> xPeer (rxWindow, UNO_QUERY);
166cdf0e10cSrcweir         if (xPeer.is())
167cdf0e10cSrcweir             xPeer->invalidateRect(rRepaintBox, nInvalidateFlags);
168cdf0e10cSrcweir     }
169cdf0e10cSrcweir }
170cdf0e10cSrcweir 
171cdf0e10cSrcweir } }
172