2014-05-22 02:51:15 +10:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <vcl/event.hxx>
|
|
|
|
#include <vcl/window.hxx>
|
|
|
|
#include <vcl/dockwin.hxx>
|
|
|
|
#include <vcl/layout.hxx>
|
|
|
|
|
|
|
|
#include <window.h>
|
|
|
|
#include <svdata.hxx>
|
|
|
|
#include <salframe.hxx>
|
|
|
|
|
|
|
|
#include <com/sun/star/awt/MouseEvent.hpp>
|
|
|
|
#include <com/sun/star/awt/KeyModifier.hpp>
|
|
|
|
#include <com/sun/star/awt/MouseButton.hpp>
|
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
namespace vcl {
|
|
|
|
|
2014-05-22 02:51:15 +10:00
|
|
|
void Window::DataChanged( const DataChangedEvent& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void Window::NotifyAllChildren( DataChangedEvent& rDCEvt )
|
|
|
|
{
|
2015-05-23 19:44:15 +01:00
|
|
|
CompatDataChanged( rDCEvt );
|
2014-05-22 02:51:15 +10:00
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
vcl::Window* pChild = mpWindowImpl->mpFirstChild;
|
2014-05-22 02:51:15 +10:00
|
|
|
while ( pChild )
|
|
|
|
{
|
|
|
|
pChild->NotifyAllChildren( rDCEvt );
|
|
|
|
pChild = pChild->mpWindowImpl->mpNext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Window::PreNotify( NotifyEvent& rNEvt )
|
|
|
|
{
|
|
|
|
bool bDone = false;
|
|
|
|
if ( mpWindowImpl->mpParent && !ImplIsOverlapWindow() )
|
2015-05-23 19:44:15 +01:00
|
|
|
bDone = mpWindowImpl->mpParent->CompatPreNotify( rNEvt );
|
2014-05-22 02:51:15 +10:00
|
|
|
|
|
|
|
if ( !bDone )
|
|
|
|
{
|
2014-11-26 14:53:25 +00:00
|
|
|
if( rNEvt.GetType() == MouseNotifyEvent::GETFOCUS )
|
2014-05-22 02:51:15 +10:00
|
|
|
{
|
|
|
|
bool bCompoundFocusChanged = false;
|
|
|
|
if ( mpWindowImpl->mbCompoundControl && !mpWindowImpl->mbCompoundControlHasFocus && HasChildPathFocus() )
|
|
|
|
{
|
|
|
|
mpWindowImpl->mbCompoundControlHasFocus = true;
|
|
|
|
bCompoundFocusChanged = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bCompoundFocusChanged || ( rNEvt.GetWindow() == this ) )
|
2015-01-14 14:52:04 +00:00
|
|
|
CallEventListeners( VCLEVENT_WINDOW_GETFOCUS );
|
2014-05-22 02:51:15 +10:00
|
|
|
}
|
2014-11-26 14:53:25 +00:00
|
|
|
else if( rNEvt.GetType() == MouseNotifyEvent::LOSEFOCUS )
|
2014-05-22 02:51:15 +10:00
|
|
|
{
|
|
|
|
bool bCompoundFocusChanged = false;
|
|
|
|
if ( mpWindowImpl->mbCompoundControl && mpWindowImpl->mbCompoundControlHasFocus && !HasChildPathFocus() )
|
|
|
|
{
|
|
|
|
mpWindowImpl->mbCompoundControlHasFocus = false ;
|
|
|
|
bCompoundFocusChanged = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bCompoundFocusChanged || ( rNEvt.GetWindow() == this ) )
|
2015-01-14 14:52:04 +00:00
|
|
|
CallEventListeners( VCLEVENT_WINDOW_LOSEFOCUS );
|
2014-05-22 02:51:15 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
// #82968# mouse and key events will be notified after processing ( in ImplNotifyKeyMouseCommandEventListeners() )!
|
|
|
|
// see also ImplHandleMouseEvent(), ImplHandleKey()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return bDone;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Window::Notify( NotifyEvent& rNEvt )
|
|
|
|
{
|
|
|
|
bool nRet = false;
|
|
|
|
|
2015-02-17 17:14:14 +00:00
|
|
|
if (IsDisposed())
|
|
|
|
return false;
|
|
|
|
|
2014-05-22 02:51:15 +10:00
|
|
|
// check for docking window
|
|
|
|
// but do nothing if window is docked and locked
|
|
|
|
ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
|
|
|
|
if( pWrapper && !( !pWrapper->IsFloatingMode() && pWrapper->IsLocked() ) )
|
|
|
|
{
|
2014-11-26 14:53:25 +00:00
|
|
|
if ( rNEvt.GetType() == MouseNotifyEvent::MOUSEBUTTONDOWN )
|
2014-05-22 02:51:15 +10:00
|
|
|
{
|
|
|
|
const MouseEvent* pMEvt = rNEvt.GetMouseEvent();
|
|
|
|
bool bHit = pWrapper->GetDragArea().IsInside( pMEvt->GetPosPixel() );
|
|
|
|
if ( pMEvt->IsLeft() )
|
|
|
|
{
|
|
|
|
if ( pMEvt->IsMod1() && (pMEvt->GetClicks() == 2) )
|
|
|
|
{
|
|
|
|
// ctrl double click toggles floating mode
|
|
|
|
pWrapper->SetFloatingMode( !pWrapper->IsFloatingMode() );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if ( pMEvt->GetClicks() == 1 && bHit)
|
|
|
|
{
|
|
|
|
// allow start docking during mouse move
|
|
|
|
pWrapper->ImplEnableStartDocking();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-11-26 14:53:25 +00:00
|
|
|
else if ( rNEvt.GetType() == MouseNotifyEvent::MOUSEMOVE )
|
2014-05-22 02:51:15 +10:00
|
|
|
{
|
|
|
|
const MouseEvent* pMEvt = rNEvt.GetMouseEvent();
|
|
|
|
bool bHit = pWrapper->GetDragArea().IsInside( pMEvt->GetPosPixel() );
|
|
|
|
if ( pMEvt->IsLeft() )
|
|
|
|
{
|
|
|
|
// check if a single click initiated this sequence ( ImplStartDockingEnabled() )
|
|
|
|
// check if window is docked and
|
|
|
|
if( pWrapper->ImplStartDockingEnabled() && !pWrapper->IsFloatingMode() &&
|
|
|
|
!pWrapper->IsDocking() && bHit )
|
|
|
|
{
|
|
|
|
Point aPos = pMEvt->GetPosPixel();
|
2014-09-23 11:20:40 +02:00
|
|
|
vcl::Window* pWindow = rNEvt.GetWindow();
|
2014-05-22 02:51:15 +10:00
|
|
|
if ( pWindow != this )
|
|
|
|
{
|
|
|
|
aPos = pWindow->OutputToScreenPixel( aPos );
|
|
|
|
aPos = ScreenToOutputPixel( aPos );
|
|
|
|
}
|
|
|
|
pWrapper->ImplStartDocking( aPos );
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2014-11-26 14:53:25 +00:00
|
|
|
else if( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT )
|
2014-05-22 02:51:15 +10:00
|
|
|
{
|
2014-08-23 22:22:32 +03:00
|
|
|
const vcl::KeyCode& rKey = rNEvt.GetKeyEvent()->GetKeyCode();
|
2014-05-22 02:51:15 +10:00
|
|
|
if( rKey.GetCode() == KEY_F10 && rKey.GetModifier() &&
|
|
|
|
rKey.IsShift() && rKey.IsMod1() )
|
|
|
|
{
|
|
|
|
pWrapper->SetFloatingMode( !pWrapper->IsFloatingMode() );
|
|
|
|
/* At this point the floating toolbar frame does not have the
|
|
|
|
* input focus since these frames don't get the focus per default
|
|
|
|
* To enable keyboard handling of this toolbar set the input focus
|
|
|
|
* to the frame. This needs to be done with ToTop since GrabFocus
|
|
|
|
* would not notice any change since "this" already has the focus.
|
|
|
|
*/
|
|
|
|
if( pWrapper->IsFloatingMode() )
|
2015-05-25 10:30:37 +02:00
|
|
|
ToTop( ToTopFlags::GrabFocusOnly );
|
2014-05-22 02:51:15 +10:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// manage the dialogs
|
|
|
|
if ( (GetStyle() & (WB_DIALOGCONTROL | WB_NODIALOGCONTROL)) == WB_DIALOGCONTROL )
|
|
|
|
{
|
|
|
|
// if the parent also has dialog control activated, the parent takes over control
|
2014-11-26 14:53:25 +00:00
|
|
|
if ( (rNEvt.GetType() == MouseNotifyEvent::KEYINPUT) || (rNEvt.GetType() == MouseNotifyEvent::KEYUP) )
|
2014-05-22 02:51:15 +10:00
|
|
|
{
|
|
|
|
if ( ImplIsOverlapWindow() ||
|
|
|
|
((getNonLayoutRealParent(this)->GetStyle() & (WB_DIALOGCONTROL | WB_NODIALOGCONTROL)) != WB_DIALOGCONTROL) )
|
|
|
|
{
|
2014-11-26 14:53:25 +00:00
|
|
|
nRet = ImplDlgCtrl( *rNEvt.GetKeyEvent(), rNEvt.GetType() == MouseNotifyEvent::KEYINPUT );
|
2014-05-22 02:51:15 +10:00
|
|
|
}
|
|
|
|
}
|
2014-11-26 14:53:25 +00:00
|
|
|
else if ( (rNEvt.GetType() == MouseNotifyEvent::GETFOCUS) || (rNEvt.GetType() == MouseNotifyEvent::LOSEFOCUS) )
|
2014-05-22 02:51:15 +10:00
|
|
|
{
|
2014-11-26 14:53:25 +00:00
|
|
|
ImplDlgCtrlFocusChanged( rNEvt.GetWindow(), rNEvt.GetType() == MouseNotifyEvent::GETFOCUS );
|
|
|
|
if ( (rNEvt.GetWindow() == this) && (rNEvt.GetType() == MouseNotifyEvent::GETFOCUS) &&
|
2015-05-26 15:22:10 +02:00
|
|
|
!(GetStyle() & WB_TABSTOP) && !(mpWindowImpl->mnDlgCtrlFlags & DialogControlFlags::WantFocus) )
|
2014-05-22 02:51:15 +10:00
|
|
|
{
|
|
|
|
sal_uInt16 n = 0;
|
2015-05-26 09:12:58 +02:00
|
|
|
vcl::Window* pFirstChild = ImplGetDlgWindow( n, GetDlgWindowType::First );
|
2014-05-22 02:51:15 +10:00
|
|
|
if ( pFirstChild )
|
|
|
|
pFirstChild->ImplControlFocus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !nRet )
|
|
|
|
{
|
|
|
|
if ( mpWindowImpl->mpParent && !ImplIsOverlapWindow() )
|
2015-05-23 19:44:15 +01:00
|
|
|
nRet = mpWindowImpl->mpParent->CompatNotify( rNEvt );
|
2014-05-22 02:51:15 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
return nRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Window::CallEventListeners( sal_uLong nEvent, void* pData )
|
|
|
|
{
|
|
|
|
VclWindowEvent aEvent( this, nEvent, pData );
|
|
|
|
|
|
|
|
ImplDelData aDelData;
|
|
|
|
ImplAddDel( &aDelData );
|
|
|
|
|
2014-06-13 17:53:02 +02:00
|
|
|
Application::ImplCallEventListeners( &aEvent );
|
2014-05-22 02:51:15 +10:00
|
|
|
|
|
|
|
if ( aDelData.IsDead() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
mpWindowImpl->maEventListeners.Call( &aEvent );
|
|
|
|
|
|
|
|
if ( aDelData.IsDead() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
ImplRemoveDel( &aDelData );
|
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
vcl::Window* pWindow = this;
|
2014-05-22 02:51:15 +10:00
|
|
|
while ( pWindow )
|
|
|
|
{
|
|
|
|
pWindow->ImplAddDel( &aDelData );
|
|
|
|
|
2015-02-14 21:11:52 +00:00
|
|
|
if ( aDelData.IsDead() )
|
|
|
|
return;
|
|
|
|
|
2014-05-22 02:51:15 +10:00
|
|
|
pWindow->mpWindowImpl->maChildEventListeners.Call( &aEvent );
|
|
|
|
|
|
|
|
if ( aDelData.IsDead() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
pWindow->ImplRemoveDel( &aDelData );
|
|
|
|
|
|
|
|
pWindow = pWindow->GetParent();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Window::FireVclEvent( VclSimpleEvent* pEvent )
|
|
|
|
{
|
2014-06-13 17:53:02 +02:00
|
|
|
Application::ImplCallEventListeners(pEvent);
|
2014-05-22 02:51:15 +10:00
|
|
|
}
|
|
|
|
|
2015-04-30 10:20:00 +02:00
|
|
|
void Window::AddEventListener( const Link<>& rEventListener )
|
2014-05-22 02:51:15 +10:00
|
|
|
{
|
|
|
|
mpWindowImpl->maEventListeners.addListener( rEventListener );
|
|
|
|
}
|
|
|
|
|
2015-04-30 10:20:00 +02:00
|
|
|
void Window::RemoveEventListener( const Link<>& rEventListener )
|
2014-05-22 02:51:15 +10:00
|
|
|
{
|
|
|
|
mpWindowImpl->maEventListeners.removeListener( rEventListener );
|
|
|
|
}
|
|
|
|
|
2015-04-30 10:20:00 +02:00
|
|
|
void Window::AddChildEventListener( const Link<>& rEventListener )
|
2014-05-22 02:51:15 +10:00
|
|
|
{
|
|
|
|
mpWindowImpl->maChildEventListeners.addListener( rEventListener );
|
|
|
|
}
|
|
|
|
|
2015-04-30 10:20:00 +02:00
|
|
|
void Window::RemoveChildEventListener( const Link<>& rEventListener )
|
2014-05-22 02:51:15 +10:00
|
|
|
{
|
|
|
|
mpWindowImpl->maChildEventListeners.removeListener( rEventListener );
|
|
|
|
}
|
|
|
|
|
2015-05-07 22:08:21 +01:00
|
|
|
ImplSVEvent * Window::PostUserEvent( const Link<>& rLink, void* pCaller, bool bReferenceLink )
|
2014-05-22 02:51:15 +10:00
|
|
|
{
|
|
|
|
ImplSVEvent* pSVEvent = new ImplSVEvent;
|
|
|
|
pSVEvent->mpData = pCaller;
|
2015-04-30 10:20:00 +02:00
|
|
|
pSVEvent->mpLink = new Link<>( rLink );
|
2014-05-22 02:51:15 +10:00
|
|
|
pSVEvent->mpWindow = this;
|
|
|
|
pSVEvent->mbCall = true;
|
2015-05-07 22:08:21 +01:00
|
|
|
if (bReferenceLink)
|
|
|
|
{
|
|
|
|
// Double check that this is indeed a vcl::Window instance.
|
|
|
|
assert(dynamic_cast<vcl::Window *>(
|
2015-05-08 22:58:55 +02:00
|
|
|
static_cast<vcl::Window *>(rLink.GetInstance())) ==
|
|
|
|
static_cast<vcl::Window *>(rLink.GetInstance()));
|
|
|
|
pSVEvent->mpInstanceRef = static_cast<vcl::Window *>(rLink.GetInstance());
|
2015-05-07 22:08:21 +01:00
|
|
|
}
|
|
|
|
|
2014-05-22 02:51:15 +10:00
|
|
|
ImplAddDel( &(pSVEvent->maDelData) );
|
|
|
|
if ( !mpWindowImpl->mpFrame->PostEvent( pSVEvent ) )
|
|
|
|
{
|
|
|
|
ImplRemoveDel( &(pSVEvent->maDelData) );
|
|
|
|
delete pSVEvent->mpLink;
|
|
|
|
delete pSVEvent;
|
|
|
|
pSVEvent = 0;
|
|
|
|
}
|
|
|
|
return pSVEvent;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Window::RemoveUserEvent( ImplSVEvent * nUserEvent )
|
|
|
|
{
|
2015-03-09 14:29:30 +02:00
|
|
|
DBG_ASSERT( nUserEvent->mpWindow.get() == this,
|
2014-05-22 02:51:15 +10:00
|
|
|
"Window::RemoveUserEvent(): Event doesn't send to this window or is already removed" );
|
|
|
|
DBG_ASSERT( nUserEvent->mbCall,
|
|
|
|
"Window::RemoveUserEvent(): Event is already removed" );
|
|
|
|
|
|
|
|
if ( nUserEvent->mpWindow )
|
|
|
|
{
|
|
|
|
nUserEvent->mpWindow->ImplRemoveDel( &(nUserEvent->maDelData) );
|
|
|
|
nUserEvent->mpWindow = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
nUserEvent->mbCall = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
MouseEvent ImplTranslateMouseEvent( const MouseEvent& rE, vcl::Window* pSource, vcl::Window* pDest )
|
2014-05-22 02:51:15 +10:00
|
|
|
{
|
|
|
|
Point aPos = pSource->OutputToScreenPixel( rE.GetPosPixel() );
|
|
|
|
aPos = pDest->ScreenToOutputPixel( aPos );
|
|
|
|
return MouseEvent( aPos, rE.GetClicks(), rE.GetMode(), rE.GetButtons(), rE.GetModifier() );
|
|
|
|
}
|
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
CommandEvent ImplTranslateCommandEvent( const CommandEvent& rCEvt, vcl::Window* pSource, vcl::Window* pDest )
|
2014-05-22 02:51:15 +10:00
|
|
|
{
|
|
|
|
if ( !rCEvt.IsMouseEvent() )
|
|
|
|
return rCEvt;
|
|
|
|
|
|
|
|
Point aPos = pSource->OutputToScreenPixel( rCEvt.GetMousePosPixel() );
|
|
|
|
aPos = pDest->ScreenToOutputPixel( aPos );
|
2015-01-14 10:50:58 +00:00
|
|
|
return CommandEvent( aPos, rCEvt.GetCommand(), rCEvt.IsMouseEvent(), rCEvt.GetEventData() );
|
2014-05-22 02:51:15 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
void Window::ImplNotifyKeyMouseCommandEventListeners( NotifyEvent& rNEvt )
|
|
|
|
{
|
2014-11-26 14:53:25 +00:00
|
|
|
if( rNEvt.GetType() == MouseNotifyEvent::COMMAND )
|
2014-05-22 02:51:15 +10:00
|
|
|
{
|
|
|
|
const CommandEvent* pCEvt = rNEvt.GetCommandEvent();
|
2015-05-07 15:25:20 +02:00
|
|
|
if ( pCEvt->GetCommand() != CommandEventId::ContextMenu )
|
2014-05-22 02:51:15 +10:00
|
|
|
// non context menu events are not to be notified up the chain
|
|
|
|
// so we return immediately
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) )
|
|
|
|
{
|
|
|
|
if ( rNEvt.GetWindow() == this )
|
|
|
|
// not interested in: The event listeners are already called in ::Command,
|
|
|
|
// and calling them here a second time doesn't make sense
|
|
|
|
;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CommandEvent aCommandEvent = ImplTranslateCommandEvent( *pCEvt, rNEvt.GetWindow(), this );
|
2015-01-14 14:52:04 +00:00
|
|
|
CallEventListeners( VCLEVENT_WINDOW_COMMAND, &aCommandEvent );
|
2014-05-22 02:51:15 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// #82968# notify event listeners for mouse and key events separately and
|
|
|
|
// not in PreNotify ( as for focus listeners )
|
|
|
|
// this allows for processing those events internally first and pass it to
|
|
|
|
// the toolkit later
|
|
|
|
|
|
|
|
ImplDelData aDelData;
|
|
|
|
ImplAddDel( &aDelData );
|
|
|
|
|
2014-11-26 14:53:25 +00:00
|
|
|
if( rNEvt.GetType() == MouseNotifyEvent::MOUSEMOVE )
|
2014-05-22 02:51:15 +10:00
|
|
|
{
|
|
|
|
if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) )
|
|
|
|
{
|
|
|
|
if ( rNEvt.GetWindow() == this )
|
2015-06-08 16:29:41 +02:00
|
|
|
CallEventListeners( VCLEVENT_WINDOW_MOUSEMOVE, const_cast<MouseEvent *>(rNEvt.GetMouseEvent()) );
|
2014-05-22 02:51:15 +10:00
|
|
|
else
|
|
|
|
{
|
|
|
|
MouseEvent aMouseEvent = ImplTranslateMouseEvent( *rNEvt.GetMouseEvent(), rNEvt.GetWindow(), this );
|
2015-01-14 14:52:04 +00:00
|
|
|
CallEventListeners( VCLEVENT_WINDOW_MOUSEMOVE, &aMouseEvent );
|
2014-05-22 02:51:15 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-11-26 14:53:25 +00:00
|
|
|
else if( rNEvt.GetType() == MouseNotifyEvent::MOUSEBUTTONUP )
|
2014-05-22 02:51:15 +10:00
|
|
|
{
|
|
|
|
if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) )
|
|
|
|
{
|
|
|
|
if ( rNEvt.GetWindow() == this )
|
2015-06-08 16:29:41 +02:00
|
|
|
CallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONUP, const_cast<MouseEvent *>(rNEvt.GetMouseEvent()) );
|
2014-05-22 02:51:15 +10:00
|
|
|
else
|
|
|
|
{
|
|
|
|
MouseEvent aMouseEvent = ImplTranslateMouseEvent( *rNEvt.GetMouseEvent(), rNEvt.GetWindow(), this );
|
2015-01-14 14:52:04 +00:00
|
|
|
CallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONUP, &aMouseEvent );
|
2014-05-22 02:51:15 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-11-26 14:53:25 +00:00
|
|
|
else if( rNEvt.GetType() == MouseNotifyEvent::MOUSEBUTTONDOWN )
|
2014-05-22 02:51:15 +10:00
|
|
|
{
|
|
|
|
if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) )
|
|
|
|
{
|
|
|
|
if ( rNEvt.GetWindow() == this )
|
2015-06-08 16:29:41 +02:00
|
|
|
CallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, const_cast<MouseEvent *>(rNEvt.GetMouseEvent()) );
|
2014-05-22 02:51:15 +10:00
|
|
|
else
|
|
|
|
{
|
|
|
|
MouseEvent aMouseEvent = ImplTranslateMouseEvent( *rNEvt.GetMouseEvent(), rNEvt.GetWindow(), this );
|
2015-01-14 14:52:04 +00:00
|
|
|
CallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, &aMouseEvent );
|
2014-05-22 02:51:15 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-11-26 14:53:25 +00:00
|
|
|
else if( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT )
|
2014-05-22 02:51:15 +10:00
|
|
|
{
|
|
|
|
if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) )
|
2015-06-08 16:29:41 +02:00
|
|
|
CallEventListeners( VCLEVENT_WINDOW_KEYINPUT, const_cast<KeyEvent *>(rNEvt.GetKeyEvent()) );
|
2014-05-22 02:51:15 +10:00
|
|
|
}
|
2014-11-26 14:53:25 +00:00
|
|
|
else if( rNEvt.GetType() == MouseNotifyEvent::KEYUP )
|
2014-05-22 02:51:15 +10:00
|
|
|
{
|
|
|
|
if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) )
|
2015-06-08 16:29:41 +02:00
|
|
|
CallEventListeners( VCLEVENT_WINDOW_KEYUP, const_cast<KeyEvent *>(rNEvt.GetKeyEvent()) );
|
2014-05-22 02:51:15 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( aDelData.IsDead() )
|
|
|
|
return;
|
|
|
|
ImplRemoveDel( &aDelData );
|
|
|
|
|
|
|
|
// #106721# check if we're part of a compound control and notify
|
2014-09-23 11:20:40 +02:00
|
|
|
vcl::Window *pParent = ImplGetParent();
|
2014-05-22 02:51:15 +10:00
|
|
|
while( pParent )
|
|
|
|
{
|
|
|
|
if( pParent->IsCompoundControl() )
|
|
|
|
{
|
|
|
|
pParent->ImplNotifyKeyMouseCommandEventListeners( rNEvt );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pParent = pParent->ImplGetParent();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Window::ImplCallInitShow()
|
|
|
|
{
|
|
|
|
mpWindowImpl->mbReallyShown = true;
|
|
|
|
mpWindowImpl->mbInInitShow = true;
|
2015-05-23 19:44:15 +01:00
|
|
|
CompatStateChanged( StateChangedType::InitShow );
|
2014-05-22 02:51:15 +10:00
|
|
|
mpWindowImpl->mbInInitShow = false;
|
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
vcl::Window* pWindow = mpWindowImpl->mpFirstOverlap;
|
2014-05-22 02:51:15 +10:00
|
|
|
while ( pWindow )
|
|
|
|
{
|
|
|
|
if ( pWindow->mpWindowImpl->mbVisible )
|
|
|
|
pWindow->ImplCallInitShow();
|
|
|
|
pWindow = pWindow->mpWindowImpl->mpNext;
|
|
|
|
}
|
|
|
|
|
|
|
|
pWindow = mpWindowImpl->mpFirstChild;
|
|
|
|
while ( pWindow )
|
|
|
|
{
|
|
|
|
if ( pWindow->mpWindowImpl->mbVisible )
|
|
|
|
pWindow->ImplCallInitShow();
|
|
|
|
pWindow = pWindow->mpWindowImpl->mpNext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Window::ImplCallResize()
|
|
|
|
{
|
|
|
|
mpWindowImpl->mbCallResize = false;
|
|
|
|
|
|
|
|
if( GetBackground().IsGradient() )
|
|
|
|
Invalidate();
|
|
|
|
|
|
|
|
Resize();
|
|
|
|
|
|
|
|
// #88419# Most classes don't call the base class in Resize() and Move(),
|
|
|
|
// => Call ImpleResize/Move instead of Resize/Move directly...
|
2015-01-14 14:52:04 +00:00
|
|
|
CallEventListeners( VCLEVENT_WINDOW_RESIZE );
|
2014-05-22 02:51:15 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
void Window::ImplCallMove()
|
|
|
|
{
|
|
|
|
mpWindowImpl->mbCallMove = false;
|
|
|
|
|
|
|
|
if( mpWindowImpl->mbFrame )
|
|
|
|
{
|
|
|
|
// update frame position
|
|
|
|
SalFrame *pParentFrame = NULL;
|
2014-09-23 11:20:40 +02:00
|
|
|
vcl::Window *pParent = ImplGetParent();
|
2014-05-22 02:51:15 +10:00
|
|
|
while( pParent )
|
|
|
|
{
|
|
|
|
if( pParent->mpWindowImpl->mpFrame != mpWindowImpl->mpFrame )
|
|
|
|
{
|
|
|
|
pParentFrame = pParent->mpWindowImpl->mpFrame;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pParent = pParent->GetParent();
|
|
|
|
}
|
|
|
|
|
|
|
|
SalFrameGeometry g = mpWindowImpl->mpFrame->GetGeometry();
|
|
|
|
mpWindowImpl->maPos = Point( g.nX, g.nY );
|
|
|
|
if( pParentFrame )
|
|
|
|
{
|
|
|
|
g = pParentFrame->GetGeometry();
|
|
|
|
mpWindowImpl->maPos -= Point( g.nX, g.nY );
|
|
|
|
}
|
2014-11-10 15:05:25 +01:00
|
|
|
// the client window and all its subclients have the same position as the borderframe
|
2014-05-22 02:51:15 +10:00
|
|
|
// this is important for floating toolbars where the borderwindow is a floating window
|
|
|
|
// which has another borderwindow (ie the system floating window)
|
2014-09-23 11:20:40 +02:00
|
|
|
vcl::Window *pClientWin = mpWindowImpl->mpClientWindow;
|
2014-05-22 02:51:15 +10:00
|
|
|
while( pClientWin )
|
|
|
|
{
|
|
|
|
pClientWin->mpWindowImpl->maPos = mpWindowImpl->maPos;
|
|
|
|
pClientWin = pClientWin->mpWindowImpl->mpClientWindow;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Move();
|
|
|
|
|
2015-01-14 14:52:04 +00:00
|
|
|
CallEventListeners( VCLEVENT_WINDOW_MOVE );
|
2014-05-22 02:51:15 +10:00
|
|
|
}
|
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
void Window::ImplCallFocusChangeActivate( vcl::Window* pNewOverlapWindow,
|
|
|
|
vcl::Window* pOldOverlapWindow )
|
2014-05-22 02:51:15 +10:00
|
|
|
{
|
|
|
|
ImplSVData* pSVData = ImplGetSVData();
|
2014-09-23 11:20:40 +02:00
|
|
|
vcl::Window* pNewRealWindow;
|
|
|
|
vcl::Window* pOldRealWindow;
|
2014-05-22 02:51:15 +10:00
|
|
|
bool bCallActivate = true;
|
|
|
|
bool bCallDeactivate = true;
|
|
|
|
|
|
|
|
pOldRealWindow = pOldOverlapWindow->ImplGetWindow();
|
|
|
|
pNewRealWindow = pNewOverlapWindow->ImplGetWindow();
|
|
|
|
if ( (pOldRealWindow->GetType() != WINDOW_FLOATINGWINDOW) ||
|
2015-05-22 15:25:59 +02:00
|
|
|
pOldRealWindow->GetActivateMode() != ActivateModeFlags::NONE )
|
2014-05-22 02:51:15 +10:00
|
|
|
{
|
|
|
|
if ( (pNewRealWindow->GetType() == WINDOW_FLOATINGWINDOW) &&
|
2015-05-22 15:25:59 +02:00
|
|
|
pNewRealWindow->GetActivateMode() == ActivateModeFlags::NONE)
|
2014-05-22 02:51:15 +10:00
|
|
|
{
|
|
|
|
pSVData->maWinData.mpLastDeacWin = pOldOverlapWindow;
|
|
|
|
bCallDeactivate = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( (pNewRealWindow->GetType() != WINDOW_FLOATINGWINDOW) ||
|
2015-05-22 15:25:59 +02:00
|
|
|
pNewRealWindow->GetActivateMode() != ActivateModeFlags::NONE )
|
2014-05-22 02:51:15 +10:00
|
|
|
{
|
|
|
|
if ( pSVData->maWinData.mpLastDeacWin )
|
|
|
|
{
|
2015-03-09 14:29:30 +02:00
|
|
|
if ( pSVData->maWinData.mpLastDeacWin.get() == pNewOverlapWindow )
|
2014-05-22 02:51:15 +10:00
|
|
|
bCallActivate = false;
|
|
|
|
else
|
|
|
|
{
|
2014-09-23 11:20:40 +02:00
|
|
|
vcl::Window* pLastRealWindow = pSVData->maWinData.mpLastDeacWin->ImplGetWindow();
|
2014-05-22 02:51:15 +10:00
|
|
|
pSVData->maWinData.mpLastDeacWin->mpWindowImpl->mbActive = false;
|
|
|
|
pSVData->maWinData.mpLastDeacWin->Deactivate();
|
2015-03-09 14:29:30 +02:00
|
|
|
if ( pLastRealWindow != pSVData->maWinData.mpLastDeacWin.get() )
|
2014-05-22 02:51:15 +10:00
|
|
|
{
|
|
|
|
pLastRealWindow->mpWindowImpl->mbActive = true;
|
|
|
|
pLastRealWindow->Activate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pSVData->maWinData.mpLastDeacWin = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bCallDeactivate )
|
|
|
|
{
|
|
|
|
if( pOldOverlapWindow->mpWindowImpl->mbActive )
|
|
|
|
{
|
|
|
|
pOldOverlapWindow->mpWindowImpl->mbActive = false;
|
|
|
|
pOldOverlapWindow->Deactivate();
|
|
|
|
}
|
|
|
|
if ( pOldRealWindow != pOldOverlapWindow )
|
|
|
|
{
|
|
|
|
if( pOldRealWindow->mpWindowImpl->mbActive )
|
|
|
|
{
|
|
|
|
pOldRealWindow->mpWindowImpl->mbActive = false;
|
|
|
|
pOldRealWindow->Deactivate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( bCallActivate && ! pNewOverlapWindow->mpWindowImpl->mbActive )
|
|
|
|
{
|
|
|
|
if( ! pNewOverlapWindow->mpWindowImpl->mbActive )
|
|
|
|
{
|
|
|
|
pNewOverlapWindow->mpWindowImpl->mbActive = true;
|
|
|
|
pNewOverlapWindow->Activate();
|
|
|
|
}
|
|
|
|
if ( pNewRealWindow != pNewOverlapWindow )
|
|
|
|
{
|
|
|
|
if( ! pNewRealWindow->mpWindowImpl->mbActive )
|
|
|
|
{
|
|
|
|
pNewRealWindow->mpWindowImpl->mbActive = true;
|
|
|
|
pNewRealWindow->Activate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
} /* namespace vcl */
|
|
|
|
|
2015-03-09 14:29:30 +02:00
|
|
|
NotifyEvent::NotifyEvent()
|
|
|
|
{
|
|
|
|
mpWindow = NULL;
|
|
|
|
mpData = NULL;
|
|
|
|
mnEventType = MouseNotifyEvent::NONE;
|
|
|
|
mnRetValue = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
NotifyEvent::NotifyEvent( MouseNotifyEvent nEventType, vcl::Window* pWindow,
|
|
|
|
const void* pEvent, long nRet )
|
|
|
|
{
|
|
|
|
mpWindow = pWindow;
|
2015-04-10 14:12:19 +01:00
|
|
|
mpData = const_cast<void*>(pEvent);
|
2015-03-09 14:29:30 +02:00
|
|
|
mnEventType = nEventType;
|
|
|
|
mnRetValue = nRet;
|
|
|
|
}
|
|
|
|
|
2014-05-22 02:51:15 +10:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|