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 <sdr/contact/viewobjectcontactofsdrmediaobj.hxx>
25 #include <vcl/window.hxx>
27 namespace sdr
{ namespace contact
{
30 SdrMediaWindow::SdrMediaWindow( vcl::Window
* pParent
, ViewObjectContactOfSdrMediaObj
& rViewObjContact
) :
31 ::avmedia::MediaWindow( pParent
, false ),
32 mrViewObjectContactOfSdrMediaObj( rViewObjContact
)
37 SdrMediaWindow::~SdrMediaWindow()
42 void SdrMediaWindow::MouseMove( const MouseEvent
& rMEvt
)
44 vcl::Window
* pWindow
= mrViewObjectContactOfSdrMediaObj
.getWindow();
46 if( pWindow
&& getWindow() )
48 const MouseEvent
aTransformedEvent( pWindow
->ScreenToOutputPixel( getWindow()->OutputToScreenPixel( rMEvt
.GetPosPixel() ) ),
49 rMEvt
.GetClicks(), rMEvt
.GetMode(), rMEvt
.GetButtons(), rMEvt
.GetModifier() );
51 pWindow
->MouseMove( aTransformedEvent
);
52 setPointer( pWindow
->GetPointer() );
57 void SdrMediaWindow::MouseButtonDown( const MouseEvent
& rMEvt
)
59 vcl::Window
* pWindow
= mrViewObjectContactOfSdrMediaObj
.getWindow();
61 if( pWindow
&& getWindow() )
63 const MouseEvent
aTransformedEvent( pWindow
->ScreenToOutputPixel( getWindow()->OutputToScreenPixel( rMEvt
.GetPosPixel() ) ),
64 rMEvt
.GetClicks(), rMEvt
.GetMode(), rMEvt
.GetButtons(), rMEvt
.GetModifier() );
66 pWindow
->MouseButtonDown( aTransformedEvent
);
71 void SdrMediaWindow::MouseButtonUp( const MouseEvent
& rMEvt
)
73 vcl::Window
* pWindow
= mrViewObjectContactOfSdrMediaObj
.getWindow();
75 if( pWindow
&& getWindow() )
77 const MouseEvent
aTransformedEvent( pWindow
->ScreenToOutputPixel( getWindow()->OutputToScreenPixel( rMEvt
.GetPosPixel() ) ),
78 rMEvt
.GetClicks(), rMEvt
.GetMode(), rMEvt
.GetButtons(), rMEvt
.GetModifier() );
80 pWindow
->MouseButtonUp( aTransformedEvent
);
85 void SdrMediaWindow::KeyInput( const KeyEvent
& rKEvt
)
87 vcl::Window
* pWindow
= mrViewObjectContactOfSdrMediaObj
.getWindow();
90 pWindow
->KeyInput( rKEvt
);
94 void SdrMediaWindow::KeyUp( const KeyEvent
& rKEvt
)
96 vcl::Window
* pWindow
= mrViewObjectContactOfSdrMediaObj
.getWindow();
99 pWindow
->KeyUp( rKEvt
);
103 void SdrMediaWindow::Command( const CommandEvent
& rCEvt
)
105 vcl::Window
* pWindow
= mrViewObjectContactOfSdrMediaObj
.getWindow();
107 if( pWindow
&& getWindow() )
109 const CommandEvent
aTransformedEvent( pWindow
->ScreenToOutputPixel( getWindow()->OutputToScreenPixel( rCEvt
.GetMousePosPixel() ) ),
110 rCEvt
.GetCommand(), rCEvt
.IsMouseEvent(), rCEvt
.GetEventData() );
112 pWindow
->Command( aTransformedEvent
);
117 sal_Int8
SdrMediaWindow::AcceptDrop( const AcceptDropEvent
& rEvt
)
119 vcl::Window
* pWindow
= mrViewObjectContactOfSdrMediaObj
.getWindow();
120 sal_Int8 nRet
= DND_ACTION_NONE
;
124 DropTargetHelper
* pDropTargetHelper
= dynamic_cast< DropTargetHelper
* >( pWindow
);
126 if( pDropTargetHelper
)
128 nRet
= pDropTargetHelper
->AcceptDrop( rEvt
);
136 sal_Int8
SdrMediaWindow::ExecuteDrop( const ExecuteDropEvent
& rEvt
)
138 vcl::Window
* pWindow
= mrViewObjectContactOfSdrMediaObj
.getWindow();
139 sal_Int8 nRet
= DND_ACTION_NONE
;
143 DropTargetHelper
* pDropTargetHelper
= dynamic_cast< DropTargetHelper
* >( pWindow
);
145 if( pDropTargetHelper
)
147 nRet
= pDropTargetHelper
->ExecuteDrop( rEvt
);
155 void SdrMediaWindow::StartDrag( sal_Int8 nAction
, const Point
& rPosPixel
)
157 vcl::Window
* pWindow
= mrViewObjectContactOfSdrMediaObj
.getWindow();
161 DragSourceHelper
* pDragSourceHelper
= dynamic_cast< DragSourceHelper
* >( pWindow
);
163 if( pDragSourceHelper
)
165 pDragSourceHelper
->StartDrag( nAction
, rPosPixel
);
172 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */