/* -*- 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 .
*/
void FocusManager::FocusPanel ( const sal_Int32 nPanelIndex, constbool bFallbackToDeckTitle)
{ if (nPanelIndex<0 || o3tl::make_unsigned(nPanelIndex)>=maPanels.size())
{ if (bFallbackToDeckTitle)
FocusDeckTitle(); return;
}
Panel& rPanel (*maPanels[nPanelIndex]);
PanelTitleBar* pTitleBar = rPanel.GetTitleBar(); if (pTitleBar && pTitleBar->GetVisible())
{
rPanel.SetExpanded(true);
pTitleBar->GetExpander().grab_focus();
} // Fallback to deck title should only be applicable when there is more than one panel, // or else it will never be possible to enter the panel contents when there's a single panel // without a titlebar and expander elseif (bFallbackToDeckTitle && maPanels.size() > 1)
{ // The panel title is not visible, fall back to the deck // title. // Make sure that the desk title is visible here to prevent a // loop when both the title of panel 0 and the deck title are // not present. if (IsDeckTitleVisible())
FocusDeckTitle(); else
FocusPanelContent(nPanelIndex);
} else
FocusPanelContent(nPanelIndex);
if (maShowPanelFunctor)
maShowPanelFunctor(rPanel);
}
void FocusManager::FocusPanelContent(const sal_Int32 nPanelIndex)
{ if (!maPanels[nPanelIndex]->IsExpanded())
maPanels[nPanelIndex]->SetExpanded(true);
switch (rKeyCode.GetCode())
{ case KEY_ESCAPE: switch (aLocation.meComponent)
{ case PC_TabBar: case PC_DeckToolBox: case PC_PanelTitle: case PC_PanelToolBox:
{ if (mxDeck)
{
mxDeck->GrabFocusToDocument();
bConsumed = true;
} break;
} case PC_PanelContent: // Return focus to tab bar sidebar settings button or panel title. if ((!IsDeckTitleVisible() && maPanels.size() == 1) ||
(!maPanels[aLocation.mnIndex]->GetTitleBar()->GetVisible()))
FocusButton(0); else
FocusPanel(aLocation.mnIndex, true);
case KEY_RETURN: switch (aLocation.meComponent)
{ case PC_PanelTitle: // Enter the panel.
FocusPanelContent(aLocation.mnIndex);
bConsumed = true; break;
default: break;
} return bConsumed;
case KEY_TAB:
{ const sal_Int32 nDirection (
rKeyCode.IsShift()
? -1
: +1); switch (aLocation.meComponent)
{ case PC_PanelTitle: case PC_PanelToolBox: if (rKeyCode.IsShift()) break;
MoveFocusInsidePanel(aLocation, nDirection);
bConsumed = true; break;
case PC_DeckToolBox:
{ // Moves to the first deck activation button that is visible and sensitive
sal_Int32 nIndex(0);
sal_Int32 nButtons(maButtons.size()); if (nButtons > 1)
{
nIndex = 1; // Finds the next visible button that is sensitive while((!maButtons[nIndex]->get_visible() ||
!maButtons[nIndex]->get_sensitive()) && ++nIndex < nButtons); // Wrap to the menu button when going past the last button if (nIndex >= nButtons)
nIndex = 0;
}
FocusButton(nIndex);
bConsumed = true;
} break;
case PC_TabBar: if (rKeyCode.IsShift())
{ if (IsDeckTitleVisible())
FocusDeckTitle(); else
FocusPanel(0, true);
} else
FocusPanel(0, true);
bConsumed = true; break;
default: break;
} break;
}
case KEY_LEFT: case KEY_UP: switch (aLocation.meComponent)
{ case PC_PanelTitle: case PC_PanelToolBox: // Go to previous panel or the deck title. if (aLocation.mnIndex > 0)
FocusPanel(aLocation.mnIndex-1, true); elseif (IsDeckTitleVisible())
FocusDeckTitle(); else
{ // Set focus to the last visible sensitive button.
sal_Int32 nIndex(maButtons.size()-1); while((!maButtons[nIndex]->get_visible() ||
!maButtons[nIndex]->get_sensitive()) && --nIndex > 0);
FocusButton(nIndex);
}
bConsumed = true; break;
case PC_TabBar:
{ if (rKeyCode.GetCode() == KEY_LEFT) break;
case KEY_RIGHT: case KEY_DOWN: switch(aLocation.meComponent)
{ case PC_PanelTitle: case PC_PanelToolBox: // Go to next panel. if (aLocation.mnIndex < static_cast<sal_Int32>(maPanels.size())-1)
FocusPanel(aLocation.mnIndex+1, false); else
FocusButton(0);
bConsumed = true; break;
case PC_TabBar:
{ if (rKeyCode.GetCode() == KEY_RIGHT) break;
// Finds the next visible sensitive button while((!maButtons[nIndex]->get_visible() ||
!maButtons[nIndex]->get_sensitive()) && ++nIndex < nButtons); // Wrap to the menu button when going past the last button if (nIndex >= nButtons)
nIndex = 0;
FocusButton(nIndex);
bConsumed = true;
} break;
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.