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 _GSTWINDOW_HXX
25 #define _GSTWINDOW_HXX
26 
27 #include "gstcommon.hxx"
28 #include <cppuhelper/interfacecontainer.h>
29 
30 #ifndef _COM_SUN_STAR_MEDIA_XPLAYERWINDOW_HDL_
31 #include "com/sun/star/media/XPlayerWindow.hdl"
32 #endif
33 
34 namespace avmedia
35 {
36 namespace gst
37 {
38 
39 class PlayerChildWindow;
40 
41 // ---------------
42 // - Window -
43 // ---------------
44 
45 class Player;
46 
47 class Window : public ::cppu::WeakImplHelper2< ::com::sun::star::media::XPlayerWindow,
48                                                ::com::sun::star::lang::XServiceInfo >
49 {
50     friend class Player;
51 
52 public:     Window( ::avmedia::gst::Player& rPlayer );
53     ~Window();
54 
55     bool create( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments );
56 
57     // XPlayerWindow
58     virtual void SAL_CALL update()
59      throw( ::com::sun::star::uno::RuntimeException );
60 
61     virtual sal_Bool SAL_CALL setZoomLevel( ::com::sun::star::media::ZoomLevel ZoomLevel )
62      throw( ::com::sun::star::uno::RuntimeException );
63     virtual ::com::sun::star::media::ZoomLevel SAL_CALL getZoomLevel()
64      throw( ::com::sun::star::uno::RuntimeException );
65 
66     virtual void SAL_CALL setPointerType( sal_Int32 nPointerType )
67      throw( ::com::sun::star::uno::RuntimeException );
68 
69     // XWindow
70     virtual void SAL_CALL setPosSize( sal_Int32 X,
71                                       sal_Int32 Y,
72                                       sal_Int32 Width,
73                                       sal_Int32 Height,
74                                       sal_Int16 Flags )
75      throw( ::com::sun::star::uno::RuntimeException );
76 
77     virtual ::com::sun::star::awt::Rectangle SAL_CALL getPosSize()
78      throw( ::com::sun::star::uno::RuntimeException );
79 
80     virtual void SAL_CALL setVisible( sal_Bool Visible )
81      throw( ::com::sun::star::uno::RuntimeException );
82 
83     virtual void SAL_CALL setEnable( sal_Bool Enable )
84      throw( ::com::sun::star::uno::RuntimeException );
85 
86     virtual void SAL_CALL setFocus()
87      throw( ::com::sun::star::uno::RuntimeException );
88 
89     virtual void SAL_CALL addWindowListener(
90         const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowListener >& xListener )
91      throw( ::com::sun::star::uno::RuntimeException );
92 
93     virtual void SAL_CALL removeWindowListener(
94         const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowListener >& xListener )
95      throw( ::com::sun::star::uno::RuntimeException );
96 
97     virtual void SAL_CALL addFocusListener(
98         const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener )
99      throw( ::com::sun::star::uno::RuntimeException );
100 
101     virtual void SAL_CALL removeFocusListener(
102         const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener )
103      throw( ::com::sun::star::uno::RuntimeException );
104 
105     virtual void SAL_CALL addKeyListener(
106         const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XKeyListener >& xListener )
107      throw( ::com::sun::star::uno::RuntimeException );
108 
109     virtual void SAL_CALL removeKeyListener(
110         const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XKeyListener >& xListener )
111      throw( ::com::sun::star::uno::RuntimeException );
112 
113     virtual void SAL_CALL addMouseListener(
114         const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener >& xListener )
115      throw( ::com::sun::star::uno::RuntimeException );
116 
117     virtual void SAL_CALL removeMouseListener(
118         const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener >& xListener )
119      throw( ::com::sun::star::uno::RuntimeException );
120 
121     virtual void SAL_CALL addMouseMotionListener(
122         const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseMotionListener >& xListener )
123      throw( ::com::sun::star::uno::RuntimeException );
124 
125     virtual void SAL_CALL removeMouseMotionListener(
126         const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseMotionListener >& xListener )
127      throw( ::com::sun::star::uno::RuntimeException );
128 
129     virtual void SAL_CALL addPaintListener(
130         const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPaintListener >& xListener )
131      throw( ::com::sun::star::uno::RuntimeException );
132 
133     virtual void SAL_CALL removePaintListener(
134         const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPaintListener >& xListener )
135      throw( ::com::sun::star::uno::RuntimeException );
136 
137     // XComponent
138     virtual void SAL_CALL dispose()
139      throw( ::com::sun::star::uno::RuntimeException );
140 
141     virtual void SAL_CALL addEventListener(
142         const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener )
143      throw( ::com::sun::star::uno::RuntimeException );
144 
145     virtual void SAL_CALL removeEventListener(
146         const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener )
147      throw( ::com::sun::star::uno::RuntimeException );
148 
149     // XServiceInfo
150     virtual ::rtl::OUString SAL_CALL getImplementationName()
151      throw( ::com::sun::star::uno::RuntimeException );
152 
153     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
154      throw( ::com::sun::star::uno::RuntimeException );
155 
156     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
157      throw( ::com::sun::star::uno::RuntimeException );
158 
159 
160 public:
161 
162     void fireMousePressedEvent( const ::com::sun::star::awt::MouseEvent& rEvt );
163 
164     void fireMouseReleasedEvent( const ::com::sun::star::awt::MouseEvent& rEvt );
165 
166     void fireMouseMovedEvent( const ::com::sun::star::awt::MouseEvent& rEvt );
167 
168     void fireKeyPressedEvent( const ::com::sun::star::awt::KeyEvent& rEvt );
169 
170     void fireKeyReleasedEvent( const ::com::sun::star::awt::KeyEvent& rEvt );
171 
172     void fireSetFocusEvent( const ::com::sun::star::awt::FocusEvent& rEvt );
173 
174 protected:
175 
176     long getXWindowHandle() const;
177 
178 private:
179 
180     ::osl::Mutex maMutex;
181     ::cppu::OMultiTypeInterfaceContainerHelper maListeners;
182     ::com::sun::star::awt::Rectangle maWindowRect;
183     Player& mrPlayer;
184     PlayerChildWindow* mpPlayerWindow;
185     ::com::sun::star::media::ZoomLevel meZoomLevel;
186     sal_Int32 mnPointerType;
187 
188     void implLayoutVideoWindow();
189 };
190 } // namespace gst
191 } // namespace avmedia
192 
193 #endif // _GSTWINDOW_HXX
194