Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_ACCESSIBILITY_INC_ACCESSIBILITY_HELPER_LISTBOXHELPER_HXX
21 : #define INCLUDED_ACCESSIBILITY_INC_ACCESSIBILITY_HELPER_LISTBOXHELPER_HXX
22 :
23 : #include <accessibility/helper/IComboListBoxHelper.hxx>
24 : #include <vcl/lstbox.hxx>
25 : #include <vcl/combobox.hxx>
26 : #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
27 :
28 :
29 : // globals
30 :
31 :
32 : const sal_Int32 DEFAULT_INDEX_IN_PARENT = -1;
33 :
34 :
35 : // class VCLListBoxHelper
36 :
37 :
38 48 : template< class T > class VCLListBoxHelper : public ::accessibility::IComboListBoxHelper
39 : {
40 : private:
41 : T& m_aComboListBox;
42 :
43 : public:
44 : inline
45 24 : VCLListBoxHelper( T& _pListBox ) :
46 24 : m_aComboListBox( _pListBox ){}
47 :
48 :
49 387 : virtual OUString GetEntry( sal_Int32 nPos ) const SAL_OVERRIDE
50 : {
51 387 : return m_aComboListBox.GetEntry( nPos );
52 : }
53 :
54 0 : virtual Rectangle GetDropDownPosSizePixel() const SAL_OVERRIDE
55 : {
56 0 : Rectangle aTemp = m_aComboListBox.GetWindowExtentsRelative(NULL);
57 0 : Rectangle aRet = m_aComboListBox.GetDropDownPosSizePixel();
58 0 : aRet.Move(aTemp.TopLeft().X(),aTemp.TopLeft().Y());
59 0 : return aRet;
60 : }
61 :
62 0 : virtual Rectangle GetBoundingRectangle( sal_uInt16 nItem ) const SAL_OVERRIDE
63 : {
64 0 : Rectangle aRect;
65 0 : if ( m_aComboListBox.IsInDropDown() && IsEntryVisible( nItem ) )
66 : {
67 0 : Rectangle aTemp = m_aComboListBox.GetDropDownPosSizePixel();
68 0 : Size aSize = aTemp.GetSize();
69 0 : aSize.Height() /= m_aComboListBox.GetDisplayLineCount();
70 0 : Point aTopLeft = aTemp.TopLeft();
71 0 : aTopLeft.Y() += aSize.Height() * ( nItem - m_aComboListBox.GetTopEntry() );
72 0 : aRect = Rectangle( aTopLeft, aSize );
73 : }
74 : else
75 0 : aRect = m_aComboListBox.GetBoundingRectangle( nItem );
76 0 : return aRect;
77 : }
78 :
79 0 : virtual Rectangle GetWindowExtentsRelative( vcl::Window* pRelativeWindow ) SAL_OVERRIDE
80 : {
81 0 : return m_aComboListBox.GetWindowExtentsRelative( pRelativeWindow );
82 : }
83 :
84 0 : virtual bool IsActive() const SAL_OVERRIDE
85 : {
86 0 : return m_aComboListBox.IsActive();
87 : }
88 :
89 722 : virtual bool IsEnabled() const SAL_OVERRIDE
90 : {
91 722 : return m_aComboListBox.IsEnabled();
92 : }
93 :
94 0 : virtual bool IsEntryVisible( sal_Int32 nPos ) const SAL_OVERRIDE
95 : {
96 0 : sal_Int32 nTopEntry = m_aComboListBox.GetTopEntry();
97 0 : sal_uInt16 nLines = m_aComboListBox.GetDisplayLineCount();
98 0 : return ( nPos >= nTopEntry && nPos < ( nTopEntry + nLines ) );
99 : }
100 :
101 423 : virtual sal_uInt16 GetDisplayLineCount() const SAL_OVERRIDE
102 : {
103 423 : return m_aComboListBox.GetDisplayLineCount();
104 : }
105 :
106 0 : virtual void GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const SAL_OVERRIDE
107 : {
108 0 : m_aComboListBox.GetMaxVisColumnsAndLines(rnCols,rnLines);
109 0 : }
110 :
111 465 : virtual WinBits GetStyle() const SAL_OVERRIDE
112 : {
113 465 : return m_aComboListBox.GetStyle();
114 : }
115 :
116 34 : virtual bool IsMultiSelectionEnabled() const SAL_OVERRIDE
117 : {
118 34 : return m_aComboListBox.IsMultiSelectionEnabled();
119 : }
120 :
121 387 : virtual sal_Int32 GetTopEntry() const SAL_OVERRIDE
122 : {
123 387 : return m_aComboListBox.GetTopEntry();
124 : }
125 :
126 394 : virtual bool IsEntryPosSelected( sal_Int32 nPos ) const SAL_OVERRIDE
127 : {
128 394 : return m_aComboListBox.IsEntryPosSelected(nPos);
129 : }
130 :
131 444 : virtual sal_Int32 GetEntryCount() const SAL_OVERRIDE
132 : {
133 444 : return m_aComboListBox.GetEntryCount();
134 : }
135 :
136 0 : virtual void Select() SAL_OVERRIDE
137 : {
138 0 : m_aComboListBox.Select();
139 0 : }
140 :
141 0 : virtual void SelectEntryPos( sal_Int32 nPos, bool bSelect = true ) SAL_OVERRIDE
142 : {
143 0 : m_aComboListBox.SelectEntryPos(nPos,bSelect);
144 0 : }
145 :
146 0 : virtual sal_Int32 GetSelectEntryCount() const SAL_OVERRIDE
147 : {
148 0 : return m_aComboListBox.GetSelectEntryCount();
149 : }
150 :
151 0 : virtual void SetNoSelection() SAL_OVERRIDE
152 : {
153 0 : m_aComboListBox.SetNoSelection();
154 0 : }
155 :
156 24 : virtual sal_Int32 GetSelectEntryPos( sal_Int32 nSelIndex = 0 ) const SAL_OVERRIDE
157 : {
158 24 : return m_aComboListBox.GetSelectEntryPos(nSelIndex);
159 : }
160 :
161 48 : virtual bool IsInDropDown() const SAL_OVERRIDE
162 : {
163 48 : return m_aComboListBox.IsInDropDown();
164 : }
165 :
166 0 : virtual Rectangle GetEntryCharacterBounds( const sal_Int32 _nEntryPos, const sal_Int32 _nCharacterIndex ) const SAL_OVERRIDE
167 : {
168 0 : Rectangle aRect;
169 :
170 0 : Pair aEntryCharacterRange = m_aComboListBox.GetLineStartEnd( _nEntryPos );
171 0 : if ( aEntryCharacterRange.A() + _nCharacterIndex <= aEntryCharacterRange.B() )
172 : {
173 0 : long nIndex = aEntryCharacterRange.A() + _nCharacterIndex;
174 0 : aRect = m_aComboListBox.GetCharacterBounds( nIndex );
175 : }
176 0 : return aRect;
177 : }
178 :
179 0 : long GetIndexForPoint( const Point& rPoint, sal_Int32& nPos ) const SAL_OVERRIDE
180 : {
181 0 : return m_aComboListBox.GetIndexForPoint( rPoint, nPos );
182 : }
183 :
184 : ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard >
185 0 : GetClipboard() SAL_OVERRIDE
186 : {
187 0 : return m_aComboListBox.GetClipboard();
188 : }
189 :
190 : };
191 :
192 : #endif // INCLUDED_ACCESSIBILITY_INC_ACCESSIBILITY_HELPER_LISTBOXHELPER_HXX
193 :
194 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|