1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_VCL_SVTABBX_HXX
20 #define INCLUDED_VCL_SVTABBX_HXX
22 #include <vcl/dllapi.h>
23 #include <vcl/treelistbox.hxx>
24 #include <vcl/accessibletableprovider.hxx>
26 #include <tools/debug.hxx>
31 enum class SvTabJustify
33 AdjustRight
= static_cast<int>(SvLBoxTabFlags::ADJUST_RIGHT
),
34 AdjustLeft
= static_cast<int>(SvLBoxTabFlags::ADJUST_LEFT
),
35 AdjustCenter
= static_cast<int>(SvLBoxTabFlags::ADJUST_CENTER
)
38 struct TabListBoxEventData
40 SvTreeListEntry
* const m_pEntry
;
41 sal_uInt16
const m_nColumn
;
42 OUString
const m_sOldText
;
44 TabListBoxEventData( SvTreeListEntry
* pEntry
, sal_uInt16 nColumn
, const OUString
& rOldText
) :
45 m_pEntry( pEntry
), m_nColumn( nColumn
), m_sOldText( rOldText
) {}
48 class VCL_DLLPUBLIC SvTabListBox
: public SvTreeListBox
51 std::vector
<SvLBoxTab
> mvTabList
;
55 static OUString
GetToken( const OUString
&sStr
, sal_Int32
&nIndex
);
57 virtual void SetTabs() override
;
58 virtual void InitEntry(SvTreeListEntry
*, const OUString
&, const Image
&, const Image
&) override
;
60 OUString
GetTabEntryText( sal_uLong nPos
, sal_uInt16 nCol
) const;
61 SvTreeListEntry
* GetEntryOnPos( sal_uLong _nEntryPos
) const;
62 SvTreeListEntry
* GetChildOnPos( SvTreeListEntry
* _pParent
, sal_uLong _nEntryPos
, sal_uLong
& _rPos
) const;
65 SvTabListBox( vcl::Window
* pParent
, WinBits
);
66 virtual ~SvTabListBox() override
;
67 virtual void dispose() override
;
68 void SetTabs(sal_uInt16 nTabs
, long const pTabPositions
[], MapUnit
= MapUnit::MapAppFont
);
69 using SvTreeListBox::GetTab
;
70 void SetTab( sal_uInt16 nTab
, long nValue
, MapUnit
= MapUnit::MapAppFont
);
71 long GetLogicTab( sal_uInt16 nTab
);
73 virtual SvTreeListEntry
* InsertEntry( const OUString
& rText
, SvTreeListEntry
* pParent
= nullptr,
74 bool bChildrenOnDemand
= false,
75 sal_uLong nPos
=TREELIST_APPEND
, void* pUserData
= nullptr ) override
;
77 virtual SvTreeListEntry
* InsertEntry( const OUString
& rText
,
78 const Image
& rExpandedEntryBmp
,
79 const Image
& rCollapsedEntryBmp
,
80 SvTreeListEntry
* pParent
= nullptr,
81 bool bChildrenOnDemand
= false,
82 sal_uLong nPos
= TREELIST_APPEND
, void* pUserData
= nullptr ) override
;
84 virtual SvTreeListEntry
* InsertEntryToColumn( const OUString
&, SvTreeListEntry
* pParent
,
85 sal_uLong nPos
, sal_uInt16 nCol
, void* pUserData
= nullptr );
86 virtual SvTreeListEntry
* InsertEntryToColumn( const OUString
&, const Image
& rExpandedEntryBmp
,
87 const Image
& rCollapsedEntryBmp
, SvTreeListEntry
* pParent
,
88 sal_uLong nPos
= TREELIST_APPEND
, sal_uInt16 nCol
= 0xffff, void* pUserData
= nullptr );
90 virtual OUString
GetEntryText( SvTreeListEntry
* pEntry
) const override
;
91 static OUString
GetEntryText( SvTreeListEntry
*, sal_uInt16 nCol
);
92 OUString
GetEntryText( sal_uLong nPos
, sal_uInt16 nCol
= 0xffff ) const;
93 using SvTreeListBox::SetEntryText
;
94 void SetEntryText(const OUString
&, SvTreeListEntry
*, sal_uInt16 nCol
=0xffff);
95 OUString
GetCellText( sal_uLong nPos
, sal_uInt16 nCol
) const;
96 sal_uLong
GetEntryPos( const SvTreeListEntry
* pEntry
) const;
98 void SetTabJustify( sal_uInt16 nTab
, SvTabJustify
);
101 // class SvHeaderTabListBox ---------------------------------------------------
105 struct SvHeaderTabListBoxImpl
;
108 class VCL_DLLPUBLIC SvHeaderTabListBox
: public SvTabListBox
, public vcl::IAccessibleTableProvider
111 typedef ::std::vector
< css::uno::Reference
< css::accessibility::XAccessible
> > AccessibleChildren
;
114 std::unique_ptr
<::vcl::SvHeaderTabListBoxImpl
> m_pImpl
;
115 ::vcl::IAccessibleTabListBox
* m_pAccessible
;
116 AccessibleChildren m_aAccessibleChildren
;
118 DECL_DLLPRIVATE_LINK( ScrollHdl_Impl
, SvTreeListBox
*, void );
119 DECL_DLLPRIVATE_LINK( CreateAccessibleHdl_Impl
, HeaderBar
*, void );
121 void RecalculateAccessibleChildren();
124 SvHeaderTabListBox( vcl::Window
* pParent
, WinBits nBits
);
125 virtual ~SvHeaderTabListBox() override
;
126 virtual void dispose() override
;
128 virtual void Paint( vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& ) override
;
130 void InitHeaderBar(HeaderBar
* pHeaderBar
);
131 HeaderBar
* GetHeaderBar();
132 static bool IsItemChecked( SvTreeListEntry
* pEntry
, sal_uInt16 nCol
);
134 virtual SvTreeListEntry
* InsertEntryToColumn( const OUString
&, SvTreeListEntry
* pParent
,
135 sal_uLong nPos
, sal_uInt16 nCol
, void* pUserData
= nullptr ) override
;
136 virtual SvTreeListEntry
* InsertEntryToColumn( const OUString
&, const Image
& rExpandedEntryBmp
,
137 const Image
& rCollapsedEntryBmp
, SvTreeListEntry
* pParent
,
138 sal_uLong nPos
= TREELIST_APPEND
, sal_uInt16 nCol
= 0xffff, void* pUserData
= nullptr ) override
;
139 virtual sal_uLong
Insert( SvTreeListEntry
* pEnt
,SvTreeListEntry
* pPar
,sal_uLong nPos
=TREELIST_APPEND
) override
;
140 virtual sal_uLong
Insert( SvTreeListEntry
* pEntry
, sal_uLong nRootPos
= TREELIST_APPEND
) override
;
142 // Accessible -------------------------------------------------------------
144 bool IsTransientChildrenDisabled() const { return !AreChildrenTransient(); }
146 bool IsCellCheckBox( long _nRow
, sal_uInt16 _nColumn
, TriState
& _rState
);
148 /** @return The count of the rows. */
149 virtual long GetRowCount() const override
;
150 /** @return The count of the columns. */
151 virtual sal_uInt16
GetColumnCount() const override
;
153 /** @return The position of the current row. */
154 virtual sal_Int32
GetCurrRow() const override
;
155 /** @return The position of the current column. */
156 virtual sal_uInt16
GetCurrColumn() const override
;
158 /** @return The description of a row.
159 @param _nRow The row which description is in demand. */
160 virtual OUString
GetRowDescription( sal_Int32 _nRow
) const override
;
161 /** @return The description of a column.
162 @param _nColumn The column which description is in demand. */
163 virtual OUString
GetColumnDescription( sal_uInt16 _nColumn
) const override
;
165 /** @return <TRUE/>, if the object has a row header. */
166 virtual bool HasRowHeader() const override
; //GetColumnId
167 /** @return <TRUE/>, if the object can focus a cell. */
168 virtual bool GoToCell( sal_Int32 _nRow
, sal_uInt16 _nColumn
) override
;
170 virtual void SetNoSelection() override
;
171 using SvTabListBox::SelectAll
;
172 virtual void SelectAll() override
;
173 virtual void SelectRow( long _nRow
, bool _bSelect
= true, bool bExpand
= true ) override
;
174 virtual void SelectColumn( sal_uInt16 _nColumn
, bool _bSelect
= true ) override
;
175 virtual sal_Int32
GetSelectedRowCount() const override
;
176 virtual sal_Int32
GetSelectedColumnCount() const override
;
177 /** @return <TRUE/>, if the row is selected. */
178 virtual bool IsRowSelected( long _nRow
) const override
;
179 virtual bool IsColumnSelected( long _nColumn
) const override
;
180 virtual void GetAllSelectedRows( css::uno::Sequence
< sal_Int32
>& _rRows
) const override
;
181 virtual void GetAllSelectedColumns( css::uno::Sequence
< sal_Int32
>& _rColumns
) const override
;
183 /** @return <TRUE/>, if the cell is visible. */
184 virtual bool IsCellVisible( sal_Int32 _nRow
, sal_uInt16 _nColumn
) const override
;
185 virtual OUString
GetAccessibleCellText( long _nRow
, sal_uInt16 _nColumnPos
) const override
;
187 virtual tools::Rectangle
calcHeaderRect( bool _bIsColumnBar
, bool _bOnScreen
= true ) override
;
188 virtual tools::Rectangle
calcTableRect( bool _bOnScreen
= true ) override
;
189 virtual tools::Rectangle
GetFieldRectPixelAbs( sal_Int32 _nRow
, sal_uInt16 _nColumn
, bool _bIsHeader
, bool _bOnScreen
= true ) override
;
191 virtual css::uno::Reference
< css::accessibility::XAccessible
> CreateAccessibleCell( sal_Int32 _nRow
, sal_uInt16 _nColumn
) override
;
192 virtual css::uno::Reference
< css::accessibility::XAccessible
> CreateAccessibleRowHeader( sal_Int32 _nRow
) override
;
193 virtual css::uno::Reference
< css::accessibility::XAccessible
> CreateAccessibleColumnHeader( sal_uInt16 _nColumnPos
) override
;
195 virtual sal_Int32
GetAccessibleControlCount() const override
;
196 virtual css::uno::Reference
< css::accessibility::XAccessible
> CreateAccessibleControl( sal_Int32 _nIndex
) override
;
197 virtual bool ConvertPointToControlIndex( sal_Int32
& _rnIndex
, const Point
& _rPoint
) override
;
199 virtual bool ConvertPointToCellAddress( sal_Int32
& _rnRow
, sal_uInt16
& _rnColPos
, const Point
& _rPoint
) override
;
200 virtual bool ConvertPointToRowHeader( sal_Int32
& _rnRow
, const Point
& _rPoint
) override
;
201 virtual bool ConvertPointToColumnHeader( sal_uInt16
& _rnColPos
, const Point
& _rPoint
) override
;
203 virtual OUString
GetAccessibleObjectName( ::vcl::AccessibleBrowseBoxObjType _eType
, sal_Int32 _nPos
= -1 ) const override
;
204 virtual OUString
GetAccessibleObjectDescription( ::vcl::AccessibleBrowseBoxObjType _eType
, sal_Int32 _nPos
= -1 ) const override
;
205 virtual vcl::Window
* GetWindowInstance() override
;
207 virtual void FillAccessibleStateSet( ::utl::AccessibleStateSetHelper
& _rStateSet
, ::vcl::AccessibleBrowseBoxObjType _eType
) const override
;
208 virtual void FillAccessibleStateSetForCell( ::utl::AccessibleStateSetHelper
& _rStateSet
, sal_Int32 _nRow
, sal_uInt16 _nColumn
) const override
;
209 virtual void GrabTableFocus() override
;
212 virtual bool GetGlyphBoundRects( const Point
& rOrigin
, const OUString
& rStr
, int nIndex
, int nLen
, MetricVector
& rVector
) override
;
215 virtual tools::Rectangle
GetWindowExtentsRelative( vcl::Window
*pRelativeWindow
) const override
;
216 virtual void GrabFocus() override
;
217 virtual css::uno::Reference
< css::accessibility::XAccessible
> GetAccessible() override
;
218 /** Creates and returns the accessible object of the whole BrowseBox. */
219 virtual css::uno::Reference
< css::accessibility::XAccessible
> CreateAccessible() override
;
220 virtual vcl::Window
* GetAccessibleParentWindow() const override
;
222 virtual tools::Rectangle
GetFieldCharacterBounds(sal_Int32 _nRow
,sal_Int32 _nColumnPos
,sal_Int32 nIndex
) override
;
223 virtual sal_Int32
GetFieldIndexAtPoint(sal_Int32 _nRow
,sal_Int32 _nColumnPos
,const Point
& _rPoint
) override
;
226 #endif // INCLUDED_VCL_SVTABBX_HXX
229 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */