1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include "sdrmediawindow.hxx"
22 #include <svtools/transfer.hxx>
24 #include <svx/sdr/contact/viewobjectcontactofsdrmediaobj.hxx>
25 #include <vcl/window.hxx>
27 namespace sdr
{ namespace contact
{
33 SdrMediaWindow::SdrMediaWindow( Window
* pParent
, ViewObjectContactOfSdrMediaObj
& rViewObjContact
) :
34 ::avmedia::MediaWindow( pParent
, false ),
35 mrViewObjectContactOfSdrMediaObj( rViewObjContact
)
39 // ------------------------------------------------------------------------------
41 SdrMediaWindow::~SdrMediaWindow()
45 // ------------------------------------------------------------------------------
47 void SdrMediaWindow::MouseMove( const MouseEvent
& rMEvt
)
49 Window
* pWindow
= mrViewObjectContactOfSdrMediaObj
.getWindow();
51 if( pWindow
&& getWindow() )
53 const MouseEvent
aTransformedEvent( pWindow
->ScreenToOutputPixel( getWindow()->OutputToScreenPixel( rMEvt
.GetPosPixel() ) ),
54 rMEvt
.GetClicks(), rMEvt
.GetMode(), rMEvt
.GetButtons(), rMEvt
.GetModifier() );
56 pWindow
->MouseMove( aTransformedEvent
);
57 setPointer( pWindow
->GetPointer() );
61 // ------------------------------------------------------------------------------
63 void SdrMediaWindow::MouseButtonDown( const MouseEvent
& rMEvt
)
65 Window
* pWindow
= mrViewObjectContactOfSdrMediaObj
.getWindow();
67 if( pWindow
&& getWindow() )
69 const MouseEvent
aTransformedEvent( pWindow
->ScreenToOutputPixel( getWindow()->OutputToScreenPixel( rMEvt
.GetPosPixel() ) ),
70 rMEvt
.GetClicks(), rMEvt
.GetMode(), rMEvt
.GetButtons(), rMEvt
.GetModifier() );
72 pWindow
->MouseButtonDown( aTransformedEvent
);
76 // ------------------------------------------------------------------------------
78 void SdrMediaWindow::MouseButtonUp( const MouseEvent
& rMEvt
)
80 Window
* pWindow
= mrViewObjectContactOfSdrMediaObj
.getWindow();
82 if( pWindow
&& getWindow() )
84 const MouseEvent
aTransformedEvent( pWindow
->ScreenToOutputPixel( getWindow()->OutputToScreenPixel( rMEvt
.GetPosPixel() ) ),
85 rMEvt
.GetClicks(), rMEvt
.GetMode(), rMEvt
.GetButtons(), rMEvt
.GetModifier() );
87 pWindow
->MouseButtonUp( aTransformedEvent
);
91 // ------------------------------------------------------------------------------
93 void SdrMediaWindow::KeyInput( const KeyEvent
& rKEvt
)
95 Window
* pWindow
= mrViewObjectContactOfSdrMediaObj
.getWindow();
98 pWindow
->KeyInput( rKEvt
);
101 // ------------------------------------------------------------------------------
103 void SdrMediaWindow::KeyUp( const KeyEvent
& rKEvt
)
105 Window
* pWindow
= mrViewObjectContactOfSdrMediaObj
.getWindow();
108 pWindow
->KeyUp( rKEvt
);
111 // ------------------------------------------------------------------------------
113 void SdrMediaWindow::Command( const CommandEvent
& rCEvt
)
115 Window
* pWindow
= mrViewObjectContactOfSdrMediaObj
.getWindow();
117 if( pWindow
&& getWindow() )
119 const CommandEvent
aTransformedEvent( pWindow
->ScreenToOutputPixel( getWindow()->OutputToScreenPixel( rCEvt
.GetMousePosPixel() ) ),
120 rCEvt
.GetCommand(), rCEvt
.IsMouseEvent(), rCEvt
.GetData() );
122 pWindow
->Command( aTransformedEvent
);
126 // ------------------------------------------------------------------------------
128 sal_Int8
SdrMediaWindow::AcceptDrop( const AcceptDropEvent
& rEvt
)
130 Window
* pWindow
= mrViewObjectContactOfSdrMediaObj
.getWindow();
131 sal_Int8 nRet
= DND_ACTION_NONE
;
135 DropTargetHelper
* pDropTargetHelper
= dynamic_cast< DropTargetHelper
* >( pWindow
);
137 if( pDropTargetHelper
)
139 nRet
= pDropTargetHelper
->AcceptDrop( rEvt
);
146 // ------------------------------------------------------------------------------
148 sal_Int8
SdrMediaWindow::ExecuteDrop( const ExecuteDropEvent
& rEvt
)
150 Window
* pWindow
= mrViewObjectContactOfSdrMediaObj
.getWindow();
151 sal_Int8 nRet
= DND_ACTION_NONE
;
155 DropTargetHelper
* pDropTargetHelper
= dynamic_cast< DropTargetHelper
* >( pWindow
);
157 if( pDropTargetHelper
)
159 nRet
= pDropTargetHelper
->ExecuteDrop( rEvt
);
166 // ------------------------------------------------------------------------------
168 void SdrMediaWindow::StartDrag( sal_Int8 nAction
, const Point
& rPosPixel
)
170 Window
* pWindow
= mrViewObjectContactOfSdrMediaObj
.getWindow();
174 DragSourceHelper
* pDragSourceHelper
= dynamic_cast< DragSourceHelper
* >( pWindow
);
176 if( pDragSourceHelper
)
178 pDragSourceHelper
->StartDrag( nAction
, rPosPixel
);
185 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */