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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svx.hxx"
26 
27 #include "sdrmediawindow.hxx"
28 #include <svtools/transfer.hxx>
29 
30 #include <svx/sdr/contact/viewobjectcontactofsdrmediaobj.hxx>
31 #include <vcl/window.hxx>
32 
33 namespace sdr {	namespace contact {
34 
35 // ------------------
36 // - SdrMediaWindow -
37 // ------------------
38 
SdrMediaWindow(Window * pParent,ViewObjectContactOfSdrMediaObj & rViewObjContact)39 SdrMediaWindow::SdrMediaWindow( Window* pParent, ViewObjectContactOfSdrMediaObj& rViewObjContact ) :
40 	::avmedia::MediaWindow( pParent, false ),
41 	mrViewObjectContactOfSdrMediaObj( rViewObjContact )
42 {
43 }
44 
45 // ------------------------------------------------------------------------------
46 
~SdrMediaWindow()47 SdrMediaWindow::~SdrMediaWindow()
48 {
49 }
50 
51 // ------------------------------------------------------------------------------
52 
MouseMove(const MouseEvent & rMEvt)53 void SdrMediaWindow::MouseMove( const MouseEvent& rMEvt )
54 {
55 	Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
56 
57 	if( pWindow && getWindow() )
58 	{
59 		const MouseEvent aTransformedEvent( pWindow->ScreenToOutputPixel( getWindow()->OutputToScreenPixel( rMEvt.GetPosPixel() ) ),
60 									  		rMEvt.GetClicks(), rMEvt.GetMode(), rMEvt.GetButtons(), rMEvt.GetModifier() );
61 
62 		pWindow->MouseMove( aTransformedEvent );
63 		setPointer( pWindow->GetPointer() );
64 	}
65 }
66 
67 // ------------------------------------------------------------------------------
68 
MouseButtonDown(const MouseEvent & rMEvt)69 void SdrMediaWindow::MouseButtonDown( const MouseEvent& rMEvt )
70 {
71 	Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
72 
73 	if( pWindow && getWindow() )
74 	{
75 		const MouseEvent aTransformedEvent( pWindow->ScreenToOutputPixel( getWindow()->OutputToScreenPixel( rMEvt.GetPosPixel() ) ),
76 									  		rMEvt.GetClicks(), rMEvt.GetMode(), rMEvt.GetButtons(), rMEvt.GetModifier() );
77 
78 		pWindow->MouseButtonDown( aTransformedEvent );
79 	}
80 }
81 
82 // ------------------------------------------------------------------------------
83 
MouseButtonUp(const MouseEvent & rMEvt)84 void SdrMediaWindow::MouseButtonUp( const MouseEvent& rMEvt )
85 {
86 	Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
87 
88 	if( pWindow && getWindow() )
89 	{
90 		const MouseEvent aTransformedEvent( pWindow->ScreenToOutputPixel( getWindow()->OutputToScreenPixel( rMEvt.GetPosPixel() ) ),
91 									  		rMEvt.GetClicks(), rMEvt.GetMode(), rMEvt.GetButtons(), rMEvt.GetModifier() );
92 
93 		pWindow->MouseButtonUp( aTransformedEvent );
94 	}
95 }
96 
97 // ------------------------------------------------------------------------------
98 
KeyInput(const KeyEvent & rKEvt)99 void SdrMediaWindow::KeyInput( const KeyEvent& rKEvt )
100 {
101 	Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
102 
103 	if( pWindow )
104 		pWindow->KeyInput( rKEvt );
105 }
106 
107 // ------------------------------------------------------------------------------
108 
KeyUp(const KeyEvent & rKEvt)109 void SdrMediaWindow::KeyUp( const KeyEvent& rKEvt )
110 {
111 	Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
112 
113 	if( pWindow )
114 		pWindow->KeyUp( rKEvt );
115 }
116 
117 // ------------------------------------------------------------------------------
118 
Command(const CommandEvent & rCEvt)119 void SdrMediaWindow::Command( const CommandEvent& rCEvt )
120 {
121 	Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
122 
123 	if( pWindow && getWindow() )
124 	{
125 		const CommandEvent aTransformedEvent( pWindow->ScreenToOutputPixel( getWindow()->OutputToScreenPixel( rCEvt.GetMousePosPixel() ) ),
126 									  		  rCEvt.GetCommand(), rCEvt.IsMouseEvent(), rCEvt.GetData() );
127 
128 		pWindow->Command( aTransformedEvent );
129 	}
130 }
131 
132 // ------------------------------------------------------------------------------
133 
AcceptDrop(const AcceptDropEvent & rEvt)134 sal_Int8 SdrMediaWindow::AcceptDrop( const AcceptDropEvent& rEvt )
135 {
136 	Window* 	pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
137 	sal_Int8	nRet = DND_ACTION_NONE;
138 
139 	if( pWindow )
140 	{
141 		DropTargetHelper* pDropTargetHelper = dynamic_cast< DropTargetHelper* >( pWindow );
142 
143 		if( pDropTargetHelper )
144 		{
145 			nRet = pDropTargetHelper->AcceptDrop( rEvt );
146 		}
147 	}
148 
149 	return( nRet );
150 }
151 
152 // ------------------------------------------------------------------------------
153 
ExecuteDrop(const ExecuteDropEvent & rEvt)154 sal_Int8 SdrMediaWindow::ExecuteDrop( const ExecuteDropEvent& rEvt )
155 {
156 	Window* 	pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
157 	sal_Int8	nRet = DND_ACTION_NONE;
158 
159 	if( pWindow )
160 	{
161 		DropTargetHelper* pDropTargetHelper = dynamic_cast< DropTargetHelper* >( pWindow );
162 
163 		if( pDropTargetHelper )
164 		{
165 			nRet = pDropTargetHelper->ExecuteDrop( rEvt );
166 		}
167 	}
168 
169 	return( nRet );
170 }
171 
172 // ------------------------------------------------------------------------------
173 
StartDrag(sal_Int8 nAction,const Point & rPosPixel)174 void SdrMediaWindow::StartDrag( sal_Int8 nAction, const Point& rPosPixel )
175 {
176 	Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
177 
178 	if( pWindow )
179 	{
180 		DragSourceHelper* pDragSourceHelper = dynamic_cast< DragSourceHelper* >( pWindow );
181 
182 		if( pDragSourceHelper )
183 		{
184 			pDragSourceHelper->StartDrag( nAction, rPosPixel );
185 		}
186 	}
187 }
188 
189 } }
190