1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SD_PRESENTER_PRESENTER_SPRITE_PANE_HXX
25 #define SD_PRESENTER_PRESENTER_SPRITE_PANE_HXX
26 
27 #include "PresenterPaneBase.hxx"
28 #include "PresenterSprite.hxx"
29 #include <com/sun/star/awt/Size.hpp>
30 #include <com/sun/star/awt/XMouseListener.hpp>
31 #include <com/sun/star/awt/XMouseMotionListener.hpp>
32 #include <com/sun/star/awt/XWindowListener.hpp>
33 #include <com/sun/star/container/XChild.hpp>
34 #include <com/sun/star/drawing/XPresenterHelper.hpp>
35 #include <com/sun/star/drawing/framework/XPane.hpp>
36 #include <com/sun/star/drawing/framework/XPaneBorderPainter.hpp>
37 #include <com/sun/star/lang/XInitialization.hpp>
38 #include <com/sun/star/uno/XComponentContext.hpp>
39 #include <com/sun/star/rendering/XCanvas.hpp>
40 #include <com/sun/star/rendering/XSpriteCanvas.hpp>
41 #include <cppuhelper/basemutex.hxx>
42 #include <cppuhelper/compbase1.hxx>
43 #include <rtl/ref.hxx>
44 #include <boost/noncopyable.hpp>
45 #include <boost/shared_ptr.hpp>
46 
47 namespace css = ::com::sun::star;
48 
49 
50 namespace sdext { namespace presenter {
51 
52 /** Use a sprite to display the contents and the border of a pane.  Windows
53     are still used to define the locations and sizes of both the border and
54     the pane content.  Note that every resize results in a disposed canvas.
55     Therefore call getCanvas in every repaint or at least after every resize.
56 */
57 class PresenterSpritePane : public PresenterPaneBase
58 {
59 public:
60     PresenterSpritePane (
61         const css::uno::Reference<css::uno::XComponentContext>& rxContext,
62         const ::rtl::Reference<PresenterController>& rpPresenterController);
63     virtual ~PresenterSpritePane (void);
64 
65     virtual void SAL_CALL disposing (void);
66 
67     using css::lang::XEventListener::disposing;
68 
69     ::boost::shared_ptr<PresenterSprite> GetSprite (void);
70 
71     static ::rtl::OUString getImplementationName_static (void);
72     static css::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static (void);
73     static css::uno::Reference<css::uno::XInterface> Create(
74         const css::uno::Reference<css::uno::XComponentContext>& rxContext)
75         SAL_THROW((css::uno::Exception));
76 
77     void ShowTransparentBorder (void);
78 
79     // XPane
80 
81     virtual css::uno::Reference<css::awt::XWindow> SAL_CALL getWindow (void)
82         throw (css::uno::RuntimeException);
83 
84     virtual css::uno::Reference<css::rendering::XCanvas> SAL_CALL getCanvas (void)
85         throw (css::uno::RuntimeException);
86 
87 
88     // XWindowListener
89 
90     virtual void SAL_CALL windowResized (const css::awt::WindowEvent& rEvent)
91         throw (css::uno::RuntimeException);
92 
93     virtual void SAL_CALL windowMoved (const css::awt::WindowEvent& rEvent)
94         throw (css::uno::RuntimeException);
95 
96     virtual void SAL_CALL windowShown (const css::lang::EventObject& rEvent)
97         throw (css::uno::RuntimeException);
98 
99     virtual void SAL_CALL windowHidden (const css::lang::EventObject& rEvent)
100         throw (css::uno::RuntimeException);
101 
102 
103     // XPaintListener
104 
105     virtual void SAL_CALL windowPaint (const css::awt::PaintEvent& rEvent)
106         throw (css::uno::RuntimeException);
107 
108 
109 private:
110     css::uno::Reference<css::awt::XWindow> mxParentWindow;
111     css::uno::Reference<css::rendering::XSpriteCanvas> mxParentCanvas;
112     ::boost::shared_ptr<PresenterSprite> mpSprite;
113 
114     virtual void CreateCanvases (
115         const css::uno::Reference<css::awt::XWindow>& rxParentWindow,
116         const css::uno::Reference<css::rendering::XSpriteCanvas>& rxParentCanvas);
117     void UpdateCanvases (void);
118 };
119 
120 } } // end of namespace ::sd::presenter
121 
122 #endif
123