/* -*- 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 <string.h>
// submit events only if toolbox has the focus to avoid sending events due to mouse move bool bHasFocus = false; if ( pToolBox->HasFocus() )
bHasFocus = true; else
{ // check for subtoolbar, i.e. check if our parent is a toolbar
ToolBox* pToolBoxParent = dynamic_cast< ToolBox* >( pToolBox->GetParent() ); // subtoolbars never get the focus as key input is just forwarded, so check if the parent toolbar has it if ( pToolBoxParent && pToolBoxParent->HasFocus() )
bHasFocus = true;
}
VCLXAccessibleToolBoxItem* pItem = rxChild.get();
pItem->SetChecked( pToolBox->IsItemChecked( nItemId ) ); if ( nItemId == nFocusId )
pFocusItem = pItem;
} //Solution:If the position is not a child item,the focus should not be called if ( pFocusItem && _nPos != ToolBox::ITEM_NOTFOUND )
pFocusItem->SetFocus( true );
}
// TODO: we should make this dependent on the existence of event listeners // with the current implementation, we always create accessible object
Any aNewChild( getAccessibleChild( static_cast<sal_Int64>(_nPos) ) ); //TODO: ToolBox::ImplToolItems::size_type -> sal_Int32!
NotifyAccessibleEvent( AccessibleEventId::CHILD, Any(), aNewChild );
}
// deregister the old items for ( ToolBoxItemsMap::iterator aIter = m_aAccessibleChildren.begin();
aIter != m_aAccessibleChildren.end(); ++aIter )
{
implReleaseToolboxItem( aIter, true );
}
m_aAccessibleChildren.clear();
// register the new items
ToolBox::ImplToolItems::size_type i, nCount = pToolBox->GetItemCount(); for ( i = 0; i < nCount; ++i )
{
Any aNewValue;
aNewValue <<= getAccessibleChild(i);
NotifyAccessibleEvent( AccessibleEventId::CHILD, Any(), aNewValue );
}
}
const ToolBoxItemId nDownItem = pToolBox->GetDownItemId(); if ( !nDownItem ) // No item is currently in down state. // Moreover, calling GetItemPos with 0 will find a separator if there is any. return;
const ToolBoxItemId nCurItemId( pToolBox->GetCurItemId() ); if ( !nCurItemId ) // No item is currently active (might happen when opening the overflow popup). // Moreover, calling GetItemPos with 0 will find a separator if there is any. return;
void VCLXAccessibleToolBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
{ // to prevent an early release of the toolbox (VclEventId::ObjectDying)
Reference< XAccessibleContext > xHoldAlive = this;
switch ( rVclWindowEvent.GetId() )
{ case VclEventId::ToolboxClick: case VclEventId::ToolboxSelect:
{
VclPtr< ToolBox > pToolBox = GetAs< ToolBox >(); if ( rVclWindowEvent.GetData() )
{
UpdateChecked_Impl( static_cast<ToolBox::ImplToolItems::size_type>(reinterpret_cast<sal_IntPtr>(rVclWindowEvent.GetData())) );
UpdateIndeterminate_Impl( static_cast<ToolBox::ImplToolItems::size_type>(reinterpret_cast<sal_IntPtr>(rVclWindowEvent.GetData())) );
} elseif( pToolBox->GetItemPos(pToolBox->GetCurItemId()) != ToolBox::ITEM_NOTFOUND )
{
UpdateChecked_Impl( pToolBox->GetItemPos(pToolBox->GetCurItemId()) );
UpdateIndeterminate_Impl( pToolBox->GetItemPos(pToolBox->GetCurItemId()) );
} break;
} case VclEventId::ToolboxDoubleClick: case VclEventId::ToolboxActivate: case VclEventId::ToolboxDeactivate: //case VclEventId::ToolboxSelect: break;
case VclEventId::ToolboxItemUpdated:
{ if ( rVclWindowEvent.GetData() )
{
UpdateChecked_Impl( ToolBox::ITEM_NOTFOUND );
UpdateIndeterminate_Impl( static_cast<ToolBox::ImplToolItems::size_type>(reinterpret_cast<sal_IntPtr>(rVclWindowEvent.GetData())) );
} break;
}
case VclEventId::ToolboxHighlight:
UpdateFocus_Impl(); break;
case VclEventId::ToolboxHighlightOff:
ReleaseFocus_Impl( static_cast<ToolBox::ImplToolItems::size_type>(reinterpret_cast<sal_IntPtr>(rVclWindowEvent.GetData())) ); break;
case VclEventId::ToolboxItemAdded :
UpdateItem_Impl( static_cast<ToolBox::ImplToolItems::size_type>(reinterpret_cast<sal_IntPtr>(rVclWindowEvent.GetData())) ); break;
case VclEventId::ToolboxItemRemoved : case VclEventId::ToolboxAllItemsChanged :
{
UpdateAllItems_Impl(); break;
}
Any aNewValue;
aNewValue <<= getAccessibleChild(nPos);
NotifyAccessibleEvent( AccessibleEventId::CHILD, Any(), aNewValue ); break;
} case VclEventId::ToolboxItemTextChanged :
UpdateItemName_Impl( static_cast<ToolBox::ImplToolItems::size_type>(reinterpret_cast<sal_IntPtr>(rVclWindowEvent.GetData())) ); break;
case VclEventId::ToolboxItemEnabled : case VclEventId::ToolboxItemDisabled :
{
UpdateItemEnabled_Impl( static_cast<ToolBox::ImplToolItems::size_type>(reinterpret_cast<sal_IntPtr>(rVclWindowEvent.GetData())) ); break;
}
case VclEventId::DropdownOpen: case VclEventId::DropdownClose:
{
UpdateCustomPopupItemp_Impl( static_cast< vcl::Window* >( rVclWindowEvent.GetData() ), rVclWindowEvent.GetId() == VclEventId::DropdownOpen ); break;
}
case VclEventId::ObjectDying :
{ // if this toolbox is a subtoolbox, we have to release it from its parent
VclPtr< vcl::Window > pWin = GetAs< vcl::Window >(); if ( pWin && pWin->GetParent() &&
pWin->GetParent()->GetType() == WindowType::TOOLBOX )
{ auto pParentAccContext = pWin->GetParent()->GetAccessible()->getAccessibleContext();
VCLXAccessibleToolBox* pParent = static_cast< VCLXAccessibleToolBox* >( pParentAccContext.get() ); if ( pParent )
pParent->ReleaseSubToolBox(static_cast<ToolBox *>(pWin.get()));
}
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.