tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / svx / source / sdr / contact / sdrmediawindow.cxx
blob086e12cee0c42b2301d8e5d6bb7ec7bc14075ca8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <vcl/transfer.hxx>
24 #include <sdr/contact/viewobjectcontactofsdrmediaobj.hxx>
25 #include <vcl/window.hxx>
26 #include <vcl/commandevent.hxx>
27 #include <vcl/event.hxx>
29 namespace sdr::contact {
32 SdrMediaWindow::SdrMediaWindow( vcl::Window* pParent, ViewObjectContactOfSdrMediaObj& rViewObjContact ) :
33 ::avmedia::MediaWindow( pParent, false ),
34 mrViewObjectContactOfSdrMediaObj( rViewObjContact )
39 SdrMediaWindow::~SdrMediaWindow()
44 void SdrMediaWindow::MouseMove( const MouseEvent& rMEvt )
46 vcl::Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
48 if( pWindow && getWindow() )
50 const MouseEvent aTransformedEvent( pWindow->ScreenToOutputPixel( getWindow()->OutputToScreenPixel( rMEvt.GetPosPixel() ) ),
51 rMEvt.GetClicks(), rMEvt.GetMode(), rMEvt.GetButtons(), rMEvt.GetModifier() );
53 pWindow->MouseMove( aTransformedEvent );
54 setPointer( pWindow->GetPointer() );
59 void SdrMediaWindow::MouseButtonDown( const MouseEvent& rMEvt )
61 vcl::Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
63 if( pWindow && getWindow() )
65 const MouseEvent aTransformedEvent( pWindow->ScreenToOutputPixel( getWindow()->OutputToScreenPixel( rMEvt.GetPosPixel() ) ),
66 rMEvt.GetClicks(), rMEvt.GetMode(), rMEvt.GetButtons(), rMEvt.GetModifier() );
68 pWindow->MouseButtonDown( aTransformedEvent );
73 void SdrMediaWindow::MouseButtonUp( const MouseEvent& rMEvt )
75 vcl::Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
77 if( pWindow && getWindow() )
79 const MouseEvent aTransformedEvent( pWindow->ScreenToOutputPixel( getWindow()->OutputToScreenPixel( rMEvt.GetPosPixel() ) ),
80 rMEvt.GetClicks(), rMEvt.GetMode(), rMEvt.GetButtons(), rMEvt.GetModifier() );
82 pWindow->MouseButtonUp( aTransformedEvent );
87 void SdrMediaWindow::KeyInput( const KeyEvent& rKEvt )
89 vcl::Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
91 if( pWindow )
92 pWindow->KeyInput( rKEvt );
96 void SdrMediaWindow::KeyUp( const KeyEvent& rKEvt )
98 vcl::Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
100 if( pWindow )
101 pWindow->KeyUp( rKEvt );
105 void SdrMediaWindow::Command( const CommandEvent& rCEvt )
107 vcl::Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
109 if( pWindow && getWindow() )
111 const CommandEvent aTransformedEvent( pWindow->ScreenToOutputPixel( getWindow()->OutputToScreenPixel( rCEvt.GetMousePosPixel() ) ),
112 rCEvt.GetCommand(), rCEvt.IsMouseEvent(), rCEvt.GetEventData() );
114 pWindow->Command( aTransformedEvent );
119 sal_Int8 SdrMediaWindow::AcceptDrop( const AcceptDropEvent& rEvt )
121 vcl::Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
122 sal_Int8 nRet = DND_ACTION_NONE;
124 if( pWindow )
126 DropTargetHelper* pDropTargetHelper = dynamic_cast< DropTargetHelper* >( pWindow );
128 if( pDropTargetHelper )
130 nRet = pDropTargetHelper->AcceptDrop( rEvt );
134 return nRet;
138 sal_Int8 SdrMediaWindow::ExecuteDrop( const ExecuteDropEvent& rEvt )
140 vcl::Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
141 sal_Int8 nRet = DND_ACTION_NONE;
143 if( pWindow )
145 DropTargetHelper* pDropTargetHelper = dynamic_cast< DropTargetHelper* >( pWindow );
147 if( pDropTargetHelper )
149 nRet = pDropTargetHelper->ExecuteDrop( rEvt );
153 return nRet;
157 void SdrMediaWindow::StartDrag( sal_Int8 nAction, const Point& rPosPixel )
159 vcl::Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
161 if( pWindow )
163 DragSourceHelper* pDragSourceHelper = dynamic_cast< DragSourceHelper* >( pWindow );
165 if( pDragSourceHelper )
167 pDragSourceHelper->StartDrag( nAction, rPosPixel );
174 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */