/* -*- 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 .
*/
IMPL_LINK_NOARG(ImplDockFloatWin2, DockTimerHdl, Timer *, void)
{
SAL_WARN_IF( !mpDockWin->IsFloatingMode(), "vcl", "docktimer called but not floating" );
IMPL_LINK_NOARG(ImplDockFloatWin2, EndDockTimerHdl, Timer *, void)
{
SAL_WARN_IF( !mpDockWin->IsFloatingMode(), "vcl", "enddocktimer called but not floating" );
bool bRealMove = true; if( GetStyle() & WB_OWNERDRAWDECORATION )
{ // for windows with ownerdraw decoration // we allow docking only when the window was moved // by dragging its caption // and ignore move request due to resizing
vcl::Window *pBorder = GetWindow( GetWindowType::Border ); if( pBorder != this )
{
tools::Rectangle aBorderRect( Point(), pBorder->GetSizePixel() );
sal_Int32 nLeft, nTop, nRight, nBottom;
GetBorder( nLeft, nTop, nRight, nBottom ); // limit borderrect to the caption part only and without the resizing borders
aBorderRect.SetBottom( aBorderRect.Top() + nTop );
aBorderRect.AdjustLeft(nLeft );
aBorderRect.AdjustRight( -nRight );
/* * note: the window should only dock if KEY_MOD1 is pressed * and the user releases all mouse buttons. The real problem here * is that we don't get mouse events (at least not on X) * if the mouse is on the decoration. So we have to start an * awkward timer based process that polls the modifier/buttons * to see whether they are in the right condition shortly after the * last Move message.
*/ if( ! mnLastUserEvent )
mnLastUserEvent = Application::PostUserEvent( LINK( this, ImplDockFloatWin2, DockingHdl ), nullptr, true );
}
void ImplDockFloatWin2::Resize()
{ // forwarding of resize only required if we have no borderwindow ( GetWindow() then returns 'this' ) if( GetWindow( GetWindowType::Border ) == this )
{
FloatingWindow::Resize();
Size aSize( GetSizePixel() );
mpDockWin->GetWindow()->ImplPosSizeWindow( 0, 0, aSize.Width(), aSize.Height(), PosSizeFlags::PosSize ); // TODO: is this needed ???
}
}
void DockingManager::RemoveWindow( const vcl::Window *pWindow )
{ for( auto it = mvDockingWindows.begin(); it != mvDockingWindows.end(); ++it )
{ constauto& xWrapper = *it; if (xWrapper && xWrapper->mpDockingWindow == pWindow)
{ // deleting wrappers calls set of actions which may want to use // wrapper we want to delete - avoid crash using temporary owner // while erasing auto pTemporaryOwner = std::move(*it);
mvDockingWindows.erase( it ); break;
}
}
}
// switch off direct accessibility support for this window
// this is to avoid appearance of this window as standalone window in the accessibility hierarchy // as this window is only used as a helper for subtoolbars that are not teared-off, the parent toolbar // has to provide accessibility support (as implemented in the toolkit) // so the contained toolbar should appear as child of the corresponding toolbar item of the parent toolbar return css::uno::Reference< css::accessibility::XAccessible >();
}
void ImplDockingWindowWrapper::ToggleFloatingMode()
{ // notify dockingwindow/toolbox // note: this must be done *before* notifying the // listeners to have the toolbox in the proper state if( GetWindow()->IsDockingWindow() ) static_cast<DockingWindow*>(GetWindow())->ToggleFloatingMode();
// now notify listeners
GetWindow()->CallEventListeners( VclEventId::WindowToggleFloating );
// must be enabled in Window::Notify to prevent permanent docking during mouse move
mbStartDockingEnabled = false;
}
void ImplDockingWindowWrapper::Resizing( Size& rSize )
{ // TODO: add virtual Resizing() to class Window, so we can get rid of class DockingWindow
DockingWindow *pDockingWindow = dynamic_cast< DockingWindow* >( GetWindow() ); if( pDockingWindow )
pDockingWindow->Resizing( rSize );
}
// the new parent for popup mode
VclPtrInstance<ImplPopupFloatWin> pWin( mpParent, xWindow->GetType() == WindowType::TOOLBOX );
pWin->SetPopupModeEndHdl( LINK( this, ImplDockingWindowWrapper, PopupModeEnd ) );
// At least for DockingWindow, GetText() has a side effect of setting deferred // properties. This must be done before setting the border window (see below), // so that the border width will end up in mpWindowImpl->mnBorderWidth, not in // the border window (See DockingWindow::setPosSizeOnContainee() and // DockingWindow::GetOptimalSize()).
pWin->SetText( xWindow->GetText() );
pWin->SetOutputSizePixel( xWindow->GetSizePixel() );
// if the subtoolbar was opened via keyboard make sure that key events // will go into subtoolbar if( pParentToolBox->IsKeyEvent() )
nFlags |= FloatWinPopupFlags::GrabFocus;
mpFloatWin->StartPopupMode( pParentToolBox, nFlags );
GetWindow()->Show(); // grab focus (again) after showing docking window, as e.g. a11y focus // events require window to be visible first if (nFlags & FloatWinPopupFlags::GrabFocus)
mpFloatWin->GrabFocus();
if( pParentToolBox->IsKeyEvent() )
{ // send HOME key to subtoolbar in order to select first item
KeyEvent aEvent( 0, vcl::KeyCode( KEY_HOME ) );
GetWindow()->KeyInput(aEvent);
}
}
void ImplDockingWindowWrapper::StartPopupMode( const tools::Rectangle& rRect, FloatWinPopupFlags nFlags )
{ // do nothing if window is floating if( IsFloatingMode() ) return;
ImplPreparePopupMode();
mpFloatWin->StartPopupMode( rRect, nFlags );
GetWindow()->Show(); // grab focus (again) after showing docking window, as e.g. a11y focus // events require window to be visible first if (nFlags & FloatWinPopupFlags::GrabFocus)
mpFloatWin->GrabFocus();
}
// set parameter for handler before destroying floating window
EndPopupModeData aData( mpFloatWin->GetWindow( GetWindowType::Border )->GetPosPixel(), mpFloatWin->IsPopupModeTearOff() );
// before deleting change parent back, so we can delete the floating window alone
vcl::Window* pRealParent = xWindow->GetWindow( GetWindowType::Parent );
xWindow->mpWindowImpl->mpBorderWindow = nullptr; if ( mpOldBorderWin )
{
xWindow->SetParent( mpOldBorderWin ); static_cast<ImplBorderWindow*>(mpOldBorderWin.get())->GetBorder(
xWindow->mpWindowImpl->mnLeftBorder, xWindow->mpWindowImpl->mnTopBorder,
xWindow->mpWindowImpl->mnRightBorder, xWindow->mpWindowImpl->mnBottomBorder );
mpOldBorderWin->Resize();
}
xWindow->mpWindowImpl->mpBorderWindow = mpOldBorderWin;
xWindow->SetParent( pRealParent );
xWindow->mpWindowImpl->mpRealParent = pRealParent;
// take ownership to local variable to protect against maPopupModeEndHdl destroying this object auto xFloatWin = std::move(mpFloatWin);
maPopupModeEndHdl.Call(xFloatWin);
xFloatWin.disposeAndClear();
// call handler - which will destroy the window and thus the wrapper as well !
xWindow->CallEventListeners( VclEventId::WindowEndPopupMode, &aData );
}
// At least for DockingWindow, GetText() has a side effect of setting deferred // properties. This must be done before setting the border window (see below), // so that the border width will end up in mpWindowImpl->mnBorderWidth, not in // the border window (See DockingWindow::setPosSizeOnContainee() and // DockingWindow::GetOptimalSize()).
pWin->SetText( GetWindow()->GetText() );
// if the parent gets destroyed, we also have to reset the parent of the BorderWindow if ( mpOldBorderWin )
mpOldBorderWin->SetParent( pWin );
GetWindow()->SetParent( pWin );
pWin->SetPosPixel( Point() );
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.