/* -*- 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 .
*/
PopupMenu* pPopup = m_pMenu->GetPopupMenu(nId);
mpParentPopup->SetPopupMenu(nId, pPopup);
}
} // the menu bar could have height 0 in fullscreen mode: // so do not use always WindowHeight, as ItemHeight < WindowHeight. if ( GetSizePixel().Height() )
{ // #107747# give menuitems the height of the menubar
aItemBottomRight.AdjustY(GetOutputSizePixel().Height()-1 );
}
// ImplExecute is not modal... // #99071# do not grab the focus, otherwise it will be restored to the menubar // when the frame is reactivated later //GrabFocus();
m_pActivePopup->ImplExecute( this, tools::Rectangle( aItemTopLeft, aItemBottomRight ), FloatWinPopupFlags::Down | FloatWinPopupFlags::NoHorzPlacement, m_pMenu, bPreSelectFirst ); // does not have a window, if aborted before or if there are no entries if ( m_pActivePopup->ImplGetFloatingWindow() )
m_pActivePopup->ImplGetFloatingWindow()->AddPopupModeWindow( this ); else
m_pActivePopup = nullptr;
}
void MenuBarWindow::KillActivePopup()
{ if ( !m_pActivePopup ) return;
FloatingWindow* pFloatWin = m_pActivePopup->ImplGetFloatingWindow(); if (pFloatWin && pFloatWin->IsInCleanUp()) return; // kill it later
if ( m_pActivePopup->bInCallback )
m_pActivePopup->bCanceled = true;
m_pActivePopup->bInCallback = true;
m_pActivePopup->Deactivate();
m_pActivePopup->bInCallback = false; // check for pActivePopup, if stopped by deactivate... if (m_pActivePopup->GetWindow())
{ if (mpParentPopup)
{ for (sal_uInt16 i = 0; i < mpParentPopup->GetItemCount(); ++i)
{
sal_uInt16 nId = mpParentPopup->GetItemId(i);
MenuItemData* pParentItemData = mpParentPopup->GetItemList()->GetData(nId);
assert(pParentItemData);
pParentItemData->pSubMenu = nullptr;
}
}
m_pActivePopup->ImplGetFloatingWindow()->StopExecute();
m_pActivePopup->ImplGetFloatingWindow()->doShutdown();
m_pActivePopup->m_pWindow.disposeAndClear();
}
m_pActivePopup = nullptr;
}
if ( rMEvt.IsLeaveWindow() )
{ if ( m_nRolloveredItem != ITEMPOS_INVALID && m_nRolloveredItem != m_nHighlightedItem )
{ // there is a spurious MouseMove generated after a menu is launched from the keyboard, hence this... if (m_nHighlightedItem != ITEMPOS_INVALID)
{ bool hide = GetMBWHideAccel();
SetMBWHideAccel(ImplGetSVData()->maNWFData.mbAutoAccel);
Invalidate(); //HighlightItem( nRolloveredItem, false );
SetMBWHideAccel(hide);
} else
Invalidate(); //HighlightItem( nRolloveredItem, false );
}
if (n == ITEMPOS_INVALID)
SetMBWHideAccel(ImplGetSVData()->maNWFData.mbAutoAccel);
// #57934# close active popup if applicable, as TH's background storage works.
MenuItemData* pNextData = m_pMenu->pItemList->GetDataFromPos( n ); if (m_pActivePopup && m_pActivePopup->GetWindow() && (!pNextData || (m_pActivePopup != pNextData->pSubMenu)))
KillActivePopup(); // pActivePopup when applicable without pWin, if Rescheduled in Activate()
// activate menubar only ones per cycle... bool bJustActivated = false; if ( ( m_nHighlightedItem == ITEMPOS_INVALID ) && ( n != ITEMPOS_INVALID ) )
{
ImplGetSVData()->mpWinData->mbNoDeactivate = true; // #105406# avoid saving the focus when we already have the focus bool bNoSaveFocus = (this == ImplGetSVData()->mpWinData->mpFocusWin.get());
if( m_xSaveFocusId != nullptr )
{ if (!ImplGetSVData()->mpWinData->mbNoSaveFocus)
{
m_xSaveFocusId = nullptr; if( !bNoSaveFocus )
m_xSaveFocusId = Window::SaveFocus(); // only save focus when initially activated
} else {
; // do nothing: we 're activated again from taskpanelist, focus was already saved
}
} else
{ if( !bNoSaveFocus )
m_xSaveFocusId = Window::SaveFocus(); // only save focus when initially activated
}
m_pMenu->bInCallback = true; // set here if Activate overridden
m_pMenu->Activate();
m_pMenu->bInCallback = false;
bJustActivated = true;
} elseif ( ( m_nHighlightedItem != ITEMPOS_INVALID ) && ( n == ITEMPOS_INVALID ) )
{
m_pMenu->bInCallback = true;
m_pMenu->Deactivate();
m_pMenu->bInCallback = false;
ImplGetSVData()->mpWinData->mbNoDeactivate = false; if (!ImplGetSVData()->mpWinData->mbNoSaveFocus)
{
VclPtr<vcl::Window> xTempFocusId; if (m_xSaveFocusId && !m_xSaveFocusId->isDisposed())
xTempFocusId = m_xSaveFocusId;
m_xSaveFocusId = nullptr;
if (bAllowRestoreFocus)
{ // tdf#115227 the popup is already killed, so temporarily set us as the // focus window, so we could avoid sending superfluous activate events // to top window listeners. if (xTempFocusId || bDefaultToDocument)
ImplGetSVData()->mpWinData->mpFocusWin = this;
// #105406# restore focus to document if we could not save focus before if (!xTempFocusId && bDefaultToDocument)
GrabFocusToDocument(); else
Window::EndSaveFocus(xTempFocusId);
}
}
}
if ( m_nHighlightedItem != ITEMPOS_INVALID )
{ if ( m_nHighlightedItem != m_nRolloveredItem )
Invalidate(); //HighlightItem( nHighlightedItem, false );
staticvoid ImplAddNWFSeparator(vcl::RenderContext& rRenderContext, const Size& rSize, const MenubarValue& rMenubarValue)
{ // add a separator if // - we have an adjacent docking area // - and if toolbars would draw them as well (mbDockingAreaSeparateTB must not be set, see dockingarea.cxx) if (rMenubarValue.maTopDockingAreaHeight
&& !ImplGetSVData()->maNWFData.mbDockingAreaSeparateTB
&& !ImplGetSVData()->maNWFData.mbDockingAreaAvoidTBFrames)
{ // note: the menubar only provides the upper (dark) half of it, the rest (bright part) is drawn by the docking area
// no key events if native menus if (m_pMenu->ImplGetSalMenu() && m_pMenu->ImplGetSalMenu()->VisibleMenuBar())
{ returnfalse;
}
if ( nCode == KEY_MENU && !rKEvent.GetKeyCode().IsShift() ) // only F10, not Shift-F10
{
mbAutoPopup = false; if ( m_nHighlightedItem == ITEMPOS_INVALID )
{
ChangeHighlightItem( 0, false );
GrabFocus();
} else
{
ChangeHighlightItem( ITEMPOS_INVALID, false );
m_xSaveFocusId = nullptr;
}
bDone = true;
} elseif ( bFromMenu )
{ if ( ( nCode == KEY_LEFT ) || ( nCode == KEY_RIGHT ) ||
( nCode == KEY_HOME ) || ( nCode == KEY_END ) )
{
sal_uInt16 n = m_nHighlightedItem; if ( n == ITEMPOS_INVALID )
{ if ( nCode == KEY_LEFT)
n = 0; else
n = m_pMenu->GetItemCount()-1;
}
sal_uInt16 nLoop = n;
if (nCode == KEY_HOME)
{
n = ITEMPOS_INVALID;
nLoop = 0;
} elseif (nCode == KEY_END)
{
n = m_pMenu->GetItemCount();
nLoop = n-1;
}
do
{ if ( nCode == KEY_LEFT || nCode == KEY_END )
{ if ( n )
n--; else
n = m_pMenu->GetItemCount()-1;
} if ( nCode == KEY_RIGHT || nCode == KEY_HOME )
{
n = (n == ITEMPOS_INVALID) ? 0 : n + 1; if ( n >= m_pMenu->GetItemCount() )
n = 0;
}
void MenuBarWindow::LayoutChanged()
{ if (!m_pMenu) return;
ApplySettings(*GetOutDev());
// if the font was changed.
tools::Long nHeight = m_pMenu->ImplCalcSize(this).Height();
// depending on the native implementation or the displayable flag // the menubar windows is suppressed (ie, height=0) if (!m_pMenu->IsDisplayable() ||
(m_pMenu->ImplGetSalMenu() && m_pMenu->ImplGetSalMenu()->VisibleMenuBar()))
{
nHeight = 0;
}
setPosSizePixel(0, 0, 0, nHeight, PosSizeFlags::Height);
GetParent()->Resize();
Invalidate();
Resize();
if ( m_nHighlightedItem == ITEMPOS_INVALID )
{
mbAutoPopup = false; // do not open menu when activated by focus handling like taskpane cycling
ChangeHighlightItem( 0, false );
}
}
bool MenuBarWindow::CanGetFocus() const
{ /* #i83908# do not use the menubar if it is native or invisible this relies on MenuBar::ImplCreate setting the height of the menubar to 0 in this case
*/
SalMenu *pNativeMenu = m_pMenu ? m_pMenu->ImplGetSalMenu() : nullptr; if (pNativeMenu && pNativeMenu->VisibleMenuBar()) return pNativeMenu->CanGetFocus(); return GetSizePixel().Height() > 0;
}
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.