1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: PresenterPaintManager.cxx,v $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 // MARKER(update_precomp.py): autogen include statement, do not remove
33 #include "precompiled_sdext.hxx"
35 #include "PresenterPaintManager.hxx"
37 #include "PresenterPaneContainer.hxx"
38 #include <com/sun/star/awt/InvalidateStyle.hpp>
39 #include <com/sun/star/awt/XWindowPeer.hpp>
40 #include <boost/bind.hpp>
42 using namespace ::com::sun::star
;
43 using namespace ::com::sun::star::uno
;
45 namespace sdext
{ namespace presenter
{
47 PresenterPaintManager::PresenterPaintManager (
48 const css::uno::Reference
<css::awt::XWindow
>& rxParentWindow
,
49 const css::uno::Reference
<css::drawing::XPresenterHelper
>& rxPresenterHelper
,
50 const rtl::Reference
<PresenterPaneContainer
>& rpPaneContainer
)
51 : mxParentWindow(rxParentWindow
),
52 mxParentWindowPeer(rxParentWindow
, UNO_QUERY
),
53 mxPresenterHelper(rxPresenterHelper
),
54 mpPaneContainer(rpPaneContainer
)
61 ::boost::function
<void(const css::awt::Rectangle
& rRepaintBox
)>
62 PresenterPaintManager::GetInvalidator (
63 const css::uno::Reference
<css::awt::XWindow
>& rxWindow
,
64 const bool bSynchronous
)
67 static_cast<void (PresenterPaintManager::*)(
68 const css::uno::Reference
<css::awt::XWindow
>&,
69 const css::awt::Rectangle
&,
70 const bool)>(&PresenterPaintManager::Invalidate
),
80 void PresenterPaintManager::Invalidate (
81 const css::uno::Reference
<css::awt::XWindow
>& rxWindow
,
82 const bool bSynchronous
)
84 sal_Int16
nInvalidateMode (awt::InvalidateStyle::CHILDREN
);
86 nInvalidateMode
|= awt::InvalidateStyle::UPDATE
;
88 PresenterPaneContainer::SharedPaneDescriptor
pDescriptor(
89 mpPaneContainer
->FindContentWindow(rxWindow
));
90 if (pDescriptor
.get()==NULL
|| ! pDescriptor
->mbIsOpaque
)
91 nInvalidateMode
|= awt::InvalidateStyle::TRANSPARENT
;
93 nInvalidateMode
|= awt::InvalidateStyle::NOTRANSPARENT
;
95 Invalidate(rxWindow
, nInvalidateMode
);
101 void PresenterPaintManager::Invalidate (
102 const css::uno::Reference
<css::awt::XWindow
>& rxWindow
,
103 const sal_Int16 nInvalidateFlags
)
105 if ((nInvalidateFlags
& awt::InvalidateStyle::TRANSPARENT
) != 0)
107 // Window is transparent and parent window(s) have to be painted as
108 // well. Invalidate the parent explicitly.
109 if (mxPresenterHelper
.is() && mxParentWindowPeer
.is())
111 const awt::Rectangle
aBBox (
112 mxPresenterHelper
->getWindowExtentsRelative(rxWindow
, mxParentWindow
));
113 mxParentWindowPeer
->invalidateRect(aBBox
, nInvalidateFlags
);
118 Reference
<awt::XWindowPeer
> xPeer (rxWindow
, UNO_QUERY
);
120 xPeer
->invalidate(nInvalidateFlags
);
127 void PresenterPaintManager::Invalidate (
128 const css::uno::Reference
<css::awt::XWindow
>& rxWindow
,
129 const css::awt::Rectangle
& rRepaintBox
,
130 const bool bSynchronous
)
132 sal_Int16
nInvalidateMode (awt::InvalidateStyle::CHILDREN
);
134 nInvalidateMode
|= awt::InvalidateStyle::UPDATE
;
136 PresenterPaneContainer::SharedPaneDescriptor
pDescriptor(
137 mpPaneContainer
->FindContentWindow(rxWindow
));
138 if (pDescriptor
.get()==NULL
|| ! pDescriptor
->mbIsOpaque
)
139 nInvalidateMode
|= awt::InvalidateStyle::TRANSPARENT
;
141 nInvalidateMode
|= awt::InvalidateStyle::NOTRANSPARENT
;
143 Invalidate(rxWindow
, rRepaintBox
, nInvalidateMode
);
149 void PresenterPaintManager::Invalidate (
150 const css::uno::Reference
<css::awt::XWindow
>& rxWindow
,
151 const css::awt::Rectangle
& rRepaintBox
,
152 const sal_Int16 nInvalidateFlags
)
154 if ((nInvalidateFlags
& awt::InvalidateStyle::TRANSPARENT
) != 0)
156 // Window is transparent and parent window(s) have to be painted as
157 // well. Invalidate the parent explicitly.
158 if (mxPresenterHelper
.is() && mxParentWindowPeer
.is())
160 const awt::Rectangle
aBBox (
161 mxPresenterHelper
->getWindowExtentsRelative(rxWindow
, mxParentWindow
));
162 mxParentWindowPeer
->invalidateRect(
164 rRepaintBox
.X
+ aBBox
.X
,
165 rRepaintBox
.Y
+ aBBox
.Y
,
173 Reference
<awt::XWindowPeer
> xPeer (rxWindow
, UNO_QUERY
);
175 xPeer
->invalidateRect(rRepaintBox
, nInvalidateFlags
);