1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20
21 #include "sdrmediawindow.hxx"
22 #include <vcl/transfer.hxx>
23
24 #include <sdr/contact/viewobjectcontactofsdrmediaobj.hxx>
25 #include <vcl/window.hxx>
26 #include <vcl/commandevent.hxx>
27 #include <vcl/event.hxx>
28
29 namespace sdr::contact {
30
31
SdrMediaWindow(vcl::Window * pParent,ViewObjectContactOfSdrMediaObj & rViewObjContact)32 SdrMediaWindow::SdrMediaWindow( vcl::Window* pParent, ViewObjectContactOfSdrMediaObj& rViewObjContact ) :
33 ::avmedia::MediaWindow( pParent, false ),
34 mrViewObjectContactOfSdrMediaObj( rViewObjContact )
35 {
36 }
37
38
~SdrMediaWindow()39 SdrMediaWindow::~SdrMediaWindow()
40 {
41 }
42
43
MouseMove(const MouseEvent & rMEvt)44 void SdrMediaWindow::MouseMove( const MouseEvent& rMEvt )
45 {
46 vcl::Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
47
48 if( pWindow && getWindow() )
49 {
50 const MouseEvent aTransformedEvent( pWindow->ScreenToOutputPixel( getWindow()->OutputToScreenPixel( rMEvt.GetPosPixel() ) ),
51 rMEvt.GetClicks(), rMEvt.GetMode(), rMEvt.GetButtons(), rMEvt.GetModifier() );
52
53 pWindow->MouseMove( aTransformedEvent );
54 setPointer( pWindow->GetPointer() );
55 }
56 }
57
58
MouseButtonDown(const MouseEvent & rMEvt)59 void SdrMediaWindow::MouseButtonDown( const MouseEvent& rMEvt )
60 {
61 vcl::Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
62
63 if( pWindow && getWindow() )
64 {
65 const MouseEvent aTransformedEvent( pWindow->ScreenToOutputPixel( getWindow()->OutputToScreenPixel( rMEvt.GetPosPixel() ) ),
66 rMEvt.GetClicks(), rMEvt.GetMode(), rMEvt.GetButtons(), rMEvt.GetModifier() );
67
68 pWindow->MouseButtonDown( aTransformedEvent );
69 }
70 }
71
72
MouseButtonUp(const MouseEvent & rMEvt)73 void SdrMediaWindow::MouseButtonUp( const MouseEvent& rMEvt )
74 {
75 vcl::Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
76
77 if( pWindow && getWindow() )
78 {
79 const MouseEvent aTransformedEvent( pWindow->ScreenToOutputPixel( getWindow()->OutputToScreenPixel( rMEvt.GetPosPixel() ) ),
80 rMEvt.GetClicks(), rMEvt.GetMode(), rMEvt.GetButtons(), rMEvt.GetModifier() );
81
82 pWindow->MouseButtonUp( aTransformedEvent );
83 }
84 }
85
86
KeyInput(const KeyEvent & rKEvt)87 void SdrMediaWindow::KeyInput( const KeyEvent& rKEvt )
88 {
89 vcl::Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
90
91 if( pWindow )
92 pWindow->KeyInput( rKEvt );
93 }
94
95
KeyUp(const KeyEvent & rKEvt)96 void SdrMediaWindow::KeyUp( const KeyEvent& rKEvt )
97 {
98 vcl::Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
99
100 if( pWindow )
101 pWindow->KeyUp( rKEvt );
102 }
103
104
Command(const CommandEvent & rCEvt)105 void SdrMediaWindow::Command( const CommandEvent& rCEvt )
106 {
107 vcl::Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
108
109 if( pWindow && getWindow() )
110 {
111 const CommandEvent aTransformedEvent( pWindow->ScreenToOutputPixel( getWindow()->OutputToScreenPixel( rCEvt.GetMousePosPixel() ) ),
112 rCEvt.GetCommand(), rCEvt.IsMouseEvent(), rCEvt.GetEventData() );
113
114 pWindow->Command( aTransformedEvent );
115 }
116 }
117
118
AcceptDrop(const AcceptDropEvent & rEvt)119 sal_Int8 SdrMediaWindow::AcceptDrop( const AcceptDropEvent& rEvt )
120 {
121 vcl::Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
122 sal_Int8 nRet = DND_ACTION_NONE;
123
124 if( pWindow )
125 {
126 DropTargetHelper* pDropTargetHelper = dynamic_cast< DropTargetHelper* >( pWindow );
127
128 if( pDropTargetHelper )
129 {
130 nRet = pDropTargetHelper->AcceptDrop( rEvt );
131 }
132 }
133
134 return nRet;
135 }
136
137
ExecuteDrop(const ExecuteDropEvent & rEvt)138 sal_Int8 SdrMediaWindow::ExecuteDrop( const ExecuteDropEvent& rEvt )
139 {
140 vcl::Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
141 sal_Int8 nRet = DND_ACTION_NONE;
142
143 if( pWindow )
144 {
145 DropTargetHelper* pDropTargetHelper = dynamic_cast< DropTargetHelper* >( pWindow );
146
147 if( pDropTargetHelper )
148 {
149 nRet = pDropTargetHelper->ExecuteDrop( rEvt );
150 }
151 }
152
153 return nRet;
154 }
155
156
StartDrag(sal_Int8 nAction,const Point & rPosPixel)157 void SdrMediaWindow::StartDrag( sal_Int8 nAction, const Point& rPosPixel )
158 {
159 vcl::Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
160
161 if( pWindow )
162 {
163 DragSourceHelper* pDragSourceHelper = dynamic_cast< DragSourceHelper* >( pWindow );
164
165 if( pDragSourceHelper )
166 {
167 pDragSourceHelper->StartDrag( nAction, rPosPixel );
168 }
169 }
170 }
171
172 }
173
174 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
175