Kaydet (Commit) 9975c632 authored tarafından Caolán McNamara's avatar Caolán McNamara

rework accessibility to be layout aware

Change-Id: I9f8ddfc5007dad6f090abae7e3e0a2d637da0b37
üst 2a3a15fd
......@@ -38,6 +38,7 @@ class VCL_DLLPUBLIC FixedText : public Control
private:
sal_Int32 m_nMaxWidthChars;
sal_Int32 m_nMinWidthChars;
Window *m_pMnemonicWindow;
using Control::ImplInitSettings;
using Window::ImplInit;
......@@ -55,10 +56,13 @@ protected:
virtual const Color&
GetCanonicalTextColor( const StyleSettings& _rStyle ) const;
virtual Window* getAccessibleRelationLabelFor() const;
public:
FixedText( Window* pParent, WinBits nStyle = 0 );
FixedText( Window* pParent, const ResId& rResId );
FixedText( Window* pParent, const ResId& rResId, bool bDisableAccessibleLabelForRelation );
~FixedText();
virtual void Paint( const Rectangle& rRect );
virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags );
......@@ -75,6 +79,8 @@ public:
Size CalcMinimumSize(long nMaxWidth = 0x7fffffff) const;
virtual Size GetOptimalSize() const;
virtual bool set_property(const rtl::OString &rKey, const rtl::OString &rValue);
void set_mnemonic_widget(Window *pWindow);
Window* get_mnemonic_widget() const { return m_pMnemonicWindow; }
};
class VCL_DLLPUBLIC SelectableFixedText : public Edit
......
......@@ -44,6 +44,7 @@ public:
protected:
virtual Size calculateRequisition() const = 0;
virtual void setAllocation(const Size &rAllocation) = 0;
virtual sal_uInt16 getDefaultAccessibleRole() const;
private:
bool m_bLayoutDirty;
};
......@@ -78,6 +79,7 @@ public:
}
virtual bool set_property(const OString &rKey, const OString &rValue);
protected:
virtual sal_uInt16 getDefaultAccessibleRole() const;
void accumulateMaxes(const Size &rChildSize, Size &rSize) const;
Size finalizeMaxes(const Size &rSize, sal_uInt16 nVisibleChildren) const;
......@@ -672,6 +674,11 @@ inline bool isContainerWindow(const Window &rWindow)
return (eType == WINDOW_CONTAINER || eType == WINDOW_SCROLLWINDOW);
}
inline bool isContainerWindow(const Window *pWindow)
{
return pWindow && isContainerWindow(*pWindow);
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -53,6 +53,7 @@ class Cursor;
class DockingManager;
class ScrollBar;
class Bitmap;
class FixedText;
class Image;
class MouseEvent;
class KeyEvent;
......@@ -571,6 +572,15 @@ protected:
// FIXME: this is a hack to workaround missing layout functionality
SAL_DLLPRIVATE void ImplAdjustNWFSizes();
// These eventually are supposed to go when everything is converted to .ui
SAL_DLLPRIVATE Window* getLegacyNonLayoutAccessibleRelationMemberOf() const;
SAL_DLLPRIVATE Window* getLegacyNonLayoutAccessibleRelationLabeledBy() const;
SAL_DLLPRIVATE Window* getLegacyNonLayoutAccessibleRelationLabelFor() const;
// Let Label override the code part of GetAccessibleRelationLabelFor
virtual Window* getAccessibleRelationLabelFor() const;
virtual sal_uInt16 getDefaultAccessibleRole() const;
public:
// Single argument ctors shall be explicit.
explicit Window( Window* pParent, WinBits nStyle = 0 );
......@@ -1222,6 +1232,13 @@ public:
void add_to_size_group(boost::shared_ptr< VclSizeGroup > xGroup);
void remove_from_all_size_groups();
/*
* add/remove mnemonic label
*/
void add_mnemonic_label(FixedText *pLabel);
void remove_mnemonic_label(FixedText *pLabel);
std::vector<FixedText*> list_mnemonic_labels() const;
/*
* Move this widget to be the nNewPosition'd child of its parent
*/
......
......@@ -43,6 +43,7 @@ struct SalPaintEvent;
struct ImplDelData;
struct ImplAccessibleInfos;
class FixedText;
class Window;
class VclSizeGroup;
class VirtualDevice;
......@@ -285,6 +286,7 @@ public:
::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > mxWindowPeer;
::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > mxAccessible;
::boost::shared_ptr< VclSizeGroup > m_xSizeGroup;
::std::vector< FixedText* > m_aMnemonicLabels;
ImplAccessibleInfos* mpAccessibleInfos;
VCLXWindow* mpVCLXWindow;
Region maWinRegion; // region to 'shape' the VCL window (frame coordinates)
......
......@@ -151,6 +151,7 @@ FixedText::FixedText( Window* pParent, WinBits nStyle )
: Control(WINDOW_FIXEDTEXT)
, m_nMaxWidthChars(-1)
, m_nMinWidthChars(-1)
, m_pMnemonicWindow(NULL)
{
ImplInit( pParent, nStyle );
}
......@@ -161,6 +162,7 @@ FixedText::FixedText( Window* pParent, const ResId& rResId )
: Control(WINDOW_FIXEDTEXT)
, m_nMaxWidthChars(-1)
, m_nMinWidthChars(-1)
, m_pMnemonicWindow(NULL)
{
rResId.SetRT( RSC_TEXT );
WinBits nStyle = ImplInitRes( rResId );
......@@ -177,6 +179,7 @@ FixedText::FixedText( Window* pParent, const ResId& rResId, bool bDisableAccessi
: Control( WINDOW_FIXEDTEXT )
, m_nMaxWidthChars(-1)
, m_nMinWidthChars(-1)
, m_pMnemonicWindow(NULL)
{
rResId.SetRT( RSC_TEXT );
WinBits nStyle = ImplInitRes( rResId );
......@@ -476,6 +479,34 @@ bool FixedText::set_property(const rtl::OString &rKey, const rtl::OString &rValu
return true;
}
Window* FixedText::getAccessibleRelationLabelFor() const
{
Window *pWindow = Control::getAccessibleRelationLabelFor();
if (pWindow)
return pWindow;
return get_mnemonic_widget();
}
void FixedText::set_mnemonic_widget(Window *pWindow)
{
if (pWindow == m_pMnemonicWindow)
return;
if (m_pMnemonicWindow)
{
Window *pTempReEntryGuard = m_pMnemonicWindow;
m_pMnemonicWindow = NULL;
pTempReEntryGuard->remove_mnemonic_label(this);
}
m_pMnemonicWindow = pWindow;
if (m_pMnemonicWindow)
m_pMnemonicWindow->add_mnemonic_label(this);
}
FixedText::~FixedText()
{
set_mnemonic_widget(NULL);
}
SelectableFixedText::SelectableFixedText(Window* pParent, WinBits nStyle)
: Edit(pParent, nStyle)
{
......
......@@ -24,6 +24,7 @@
#include <window.h>
#include <vcl/event.hxx>
#include <vcl/fixed.hxx>
#include <vcl/layout.hxx>
#include <vcl/svapp.hxx>
#include <vcl/tabpage.hxx>
......@@ -434,6 +435,16 @@ static Window* ImplFindAccelWindow( Window* pParent, sal_uInt16& rIndex, sal_Uni
cCompareChar = xCharClass->toUpper( rtl::OUString(cCompareChar), 0, 1, rLocale )[0];
if ( cCompareChar == cCharCode )
{
if (pWindow->GetType() == WINDOW_FIXEDTEXT)
{
FixedText *pFixedText = static_cast<FixedText*>(pWindow);
Window *pMnemonicWidget = pFixedText->get_mnemonic_widget();
SAL_WARN_IF(isContainerWindow(pFixedText->GetParent()) && !pMnemonicWidget,
"vcl.a11y", "label missing mnemonic_widget?");
if (pMnemonicWidget)
return pMnemonicWidget;
}
// Bei Static-Controls auf das naechste Controlm weiterschalten
if ( (pWindow->GetType() == WINDOW_FIXEDTEXT) ||
(pWindow->GetType() == WINDOW_FIXEDLINE) ||
......@@ -1207,15 +1218,8 @@ static Window* ImplGetLabelFor( Window* pFrameWindow, WindowType nMyType, Window
return pWindow;
}
Window* Window::GetAccessibleRelationLabelFor() const
Window* Window::getLegacyNonLayoutAccessibleRelationLabelFor() const
{
if ( mpWindowImpl->mbDisableAccessibleLabelForRelation )
return NULL;
if ( mpWindowImpl->mpAccessibleInfos && mpWindowImpl->mpAccessibleInfos->pLabelForWindow )
return mpWindowImpl->mpAccessibleInfos->pLabelForWindow;
Window* pWindow = NULL;
Window* pFrameWindow = ImplGetFrameWindow();
......@@ -1296,14 +1300,8 @@ static Window* ImplGetLabeledBy( Window* pFrameWindow, WindowType nMyType, Windo
return pWindow;
}
Window* Window::GetAccessibleRelationLabeledBy() const
Window* Window::getLegacyNonLayoutAccessibleRelationLabeledBy() const
{
if ( mpWindowImpl->mbDisableAccessibleLabeledByRelation )
return NULL;
if ( mpWindowImpl->mpAccessibleInfos && mpWindowImpl->mpAccessibleInfos->pLabeledByWindow )
return mpWindowImpl->mpAccessibleInfos->pLabeledByWindow;
Window* pWindow = NULL;
Window* pFrameWindow = ImplGetFrameWindow();
......@@ -1332,11 +1330,8 @@ Window* Window::GetAccessibleRelationLabeledBy() const
return pWindow;
}
Window* Window::GetAccessibleRelationMemberOf() const
Window* Window::getLegacyNonLayoutAccessibleRelationMemberOf() const
{
if ( mpWindowImpl->mpAccessibleInfos && mpWindowImpl->mpAccessibleInfos->pMemberOfWindow )
return mpWindowImpl->mpAccessibleInfos->pMemberOfWindow;
Window* pWindow = NULL;
Window* pFrameWindow = GetParent();
if ( !pFrameWindow )
......
......@@ -7,6 +7,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <com/sun/star/accessibility/AccessibleRole.hpp>
#include <vcl/dialog.hxx>
#include <vcl/layout.hxx>
#include "window.h"
......@@ -21,6 +22,11 @@ VclContainer::VclContainer(Window *pParent, WinBits nStyle)
SetBackground();
}
sal_uInt16 VclContainer::getDefaultAccessibleRole() const
{
return com::sun::star::accessibility::AccessibleRole::PANEL;
}
Size VclContainer::GetOptimalSize() const
{
return calculateRequisition();
......@@ -296,6 +302,11 @@ bool VclBox::set_property(const rtl::OString &rKey, const rtl::OString &rValue)
return true;
}
sal_uInt16 VclBox::getDefaultAccessibleRole() const
{
return com::sun::star::accessibility::AccessibleRole::FILLER;
}
#define DEFAULT_CHILD_MIN_WIDTH 85
#define DEFAULT_CHILD_MIN_HEIGHT 27
......
This diff is collapsed.
......@@ -25,6 +25,7 @@
#include <vcl/bitmap.hxx>
#include <vcl/dialog.hxx>
#include <vcl/event.hxx>
#include <vcl/fixed.hxx>
#include <vcl/layout.hxx>
#include <vcl/timer.hxx>
#include <vcl/metric.hxx>
......@@ -2315,4 +2316,28 @@ void Window::remove_from_all_size_groups()
}
}
void Window::add_mnemonic_label(FixedText *pLabel)
{
std::vector<FixedText*>& v = mpWindowImpl->m_aMnemonicLabels;
if (std::find(v.begin(), v.end(), pLabel) != v.end())
return;
v.push_back(pLabel);
pLabel->set_mnemonic_widget(this);
}
void Window::remove_mnemonic_label(FixedText *pLabel)
{
std::vector<FixedText*>& v = mpWindowImpl->m_aMnemonicLabels;
std::vector<FixedText*>::iterator aFind = std::find(v.begin(), v.end(), pLabel);
if (aFind == v.end())
return;
v.erase(aFind);
pLabel->set_mnemonic_widget(NULL);
}
std::vector<FixedText*> Window::list_mnemonic_labels() const
{
return mpWindowImpl->m_aMnemonicLabels;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment