Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / include / vcl / toolkit / svtabbx.hxx
blobefed0e36df95c5c12c8005084eecaf58a36b4383
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #pragma once
22 #if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS)
23 #error "don't use this in new code"
24 #endif
26 #include <vcl/dllapi.h>
27 #include <vcl/toolkit/treelistbox.hxx>
28 #include <vcl/accessibletableprovider.hxx>
30 #include <tools/debug.hxx>
32 #include <memory>
33 #include <vector>
35 enum class SvTabJustify
37 AdjustRight = static_cast<int>(SvLBoxTabFlags::ADJUST_RIGHT),
38 AdjustLeft = static_cast<int>(SvLBoxTabFlags::ADJUST_LEFT),
39 AdjustCenter = static_cast<int>(SvLBoxTabFlags::ADJUST_CENTER)
42 class VCL_DLLPUBLIC SvTabListBox : public SvTreeListBox
44 private:
45 std::vector<SvLBoxTab> mvTabList;
46 OUString aCurEntry;
48 protected:
49 static std::u16string_view GetToken( std::u16string_view sStr, sal_Int32 &nIndex );
51 virtual void SetTabs() override;
52 virtual void InitEntry(SvTreeListEntry*, const OUString&, const Image&, const Image&) override;
54 OUString GetTabEntryText( sal_uInt32 nPos, sal_uInt16 nCol ) const;
55 SvTreeListEntry* GetEntryOnPos( sal_uInt32 _nEntryPos ) const;
56 SvTreeListEntry* GetChildOnPos( SvTreeListEntry* _pParent, sal_uInt32 _nEntryPos, sal_uInt32& _rPos ) const;
58 public:
59 SvTabListBox( vcl::Window* pParent, WinBits );
60 virtual ~SvTabListBox() override;
61 virtual void dispose() override;
62 void SetTabs(sal_uInt16 nTabs, tools::Long const pTabPositions[], MapUnit = MapUnit::MapAppFont);
63 using SvTreeListBox::GetTab;
64 tools::Long GetLogicTab( sal_uInt16 nTab );
66 virtual SvTreeListEntry* InsertEntry( const OUString& rText, SvTreeListEntry* pParent = nullptr,
67 bool bChildrenOnDemand = false,
68 sal_uInt32 nPos=TREELIST_APPEND, void* pUserData = nullptr ) override;
70 virtual SvTreeListEntry* InsertEntryToColumn( const OUString&, SvTreeListEntry* pParent,
71 sal_uInt32 nPos, sal_uInt16 nCol, void* pUserData = nullptr );
73 virtual OUString GetEntryText( SvTreeListEntry* pEntry ) const override;
74 static OUString GetEntryText( const SvTreeListEntry*, sal_uInt16 nCol );
75 OUString GetEntryText( sal_uInt32 nPos, sal_uInt16 nCol = 0xffff ) const;
76 using SvTreeListBox::SetEntryText;
77 OUString GetCellText( sal_uInt32 nPos, sal_uInt16 nCol ) const;
78 sal_uInt32 GetEntryPos( const SvTreeListEntry* pEntry ) const;
80 void SetTabJustify( sal_uInt16 nTab, SvTabJustify );
81 void SetTabEditable( sal_uInt16 nTab, bool bEditable );
83 virtual void DumpAsPropertyTree(tools::JsonWriter& rJsonWriter) override;
86 // class SvHeaderTabListBox ---------------------------------------------------
88 class HeaderBar;
89 namespace vcl {
90 struct SvHeaderTabListBoxImpl;
93 class VCL_DLLPUBLIC SvHeaderTabListBox : public SvTabListBox, public vcl::IAccessibleTableProvider
95 private:
96 typedef ::std::vector< css::uno::Reference< css::accessibility::XAccessible > > AccessibleChildren;
98 bool m_bFirstPaint;
99 std::unique_ptr<::vcl::SvHeaderTabListBoxImpl> m_pImpl;
100 ::vcl::IAccessibleTabListBox* m_pAccessible;
101 AccessibleChildren m_aAccessibleChildren;
103 DECL_DLLPRIVATE_LINK( ScrollHdl_Impl, SvTreeListBox*, void );
104 DECL_DLLPRIVATE_LINK( CreateAccessibleHdl_Impl, HeaderBar*, void );
106 void RecalculateAccessibleChildren();
108 public:
109 SvHeaderTabListBox( vcl::Window* pParent, WinBits nBits );
110 virtual ~SvHeaderTabListBox() override;
111 virtual void dispose() override;
113 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& ) override;
115 void InitHeaderBar(HeaderBar* pHeaderBar);
116 HeaderBar* GetHeaderBar();
117 static bool IsItemChecked( SvTreeListEntry* pEntry, sal_uInt16 nCol );
119 virtual SvTreeListEntry* InsertEntryToColumn( const OUString&, SvTreeListEntry* pParent,
120 sal_uInt32 nPos, sal_uInt16 nCol, void* pUserData = nullptr ) override;
121 virtual sal_uInt32 Insert( SvTreeListEntry* pEnt,SvTreeListEntry* pPar,sal_uInt32 nPos=TREELIST_APPEND) override;
122 virtual sal_uInt32 Insert( SvTreeListEntry* pEntry, sal_uInt32 nRootPos = TREELIST_APPEND ) override;
124 // Accessible -------------------------------------------------------------
126 bool IsCellCheckBox( sal_Int32 _nRow, sal_uInt16 _nColumn, TriState& _rState ) const;
128 /** @return The count of the rows. */
129 virtual sal_Int32 GetRowCount() const override;
130 /** @return The count of the columns. */
131 virtual sal_uInt16 GetColumnCount() const override;
133 /** @return The position of the current row. */
134 virtual sal_Int32 GetCurrRow() const override;
135 /** @return The position of the current column. */
136 virtual sal_uInt16 GetCurrColumn() const override;
138 /** @return The description of a row.
139 @param _nRow The row which description is in demand. */
140 virtual OUString GetRowDescription( sal_Int32 _nRow ) const override;
141 /** @return The description of a column.
142 @param _nColumn The column which description is in demand. */
143 virtual OUString GetColumnDescription( sal_uInt16 _nColumn ) const override;
145 /** @return <TRUE/>, if the object has a row header. */
146 virtual bool HasRowHeader() const override; //GetColumnId
147 /** @return <TRUE/>, if the object can focus a cell. */
148 virtual bool GoToCell( sal_Int32 _nRow, sal_uInt16 _nColumn ) override;
150 virtual void SetNoSelection() override;
151 using SvTabListBox::SelectAll;
152 virtual void SelectAll() override;
153 virtual void SelectRow( sal_Int32 _nRow, bool _bSelect = true, bool bExpand = true ) override;
154 virtual void SelectColumn( sal_uInt16 _nColumn, bool _bSelect = true ) override;
155 virtual sal_Int32 GetSelectedRowCount() const override;
156 virtual sal_Int32 GetSelectedColumnCount() const override;
157 /** @return <TRUE/>, if the row is selected. */
158 virtual bool IsRowSelected( sal_Int32 _nRow ) const override;
159 virtual bool IsColumnSelected( sal_Int32 _nColumn ) const override;
160 virtual void GetAllSelectedRows( css::uno::Sequence< sal_Int32 >& _rRows ) const override;
161 virtual void GetAllSelectedColumns( css::uno::Sequence< sal_Int32 >& _rColumns ) const override;
163 /** @return <TRUE/>, if the cell is visible. */
164 virtual bool IsCellVisible( sal_Int32 _nRow, sal_uInt16 _nColumn ) const override;
165 virtual OUString GetAccessibleCellText( sal_Int32 _nRow, sal_uInt16 _nColumnPos ) const override;
167 virtual tools::Rectangle calcHeaderRect( bool _bIsColumnBar, bool _bOnScreen = true ) override;
168 virtual tools::Rectangle calcTableRect( bool _bOnScreen = true ) override;
169 virtual tools::Rectangle GetFieldRectPixelAbs( sal_Int32 _nRow, sal_uInt16 _nColumn, bool _bIsHeader, bool _bOnScreen = true ) override;
171 virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessibleCell( sal_Int32 _nRow, sal_uInt16 _nColumn ) override;
172 virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessibleRowHeader( sal_Int32 _nRow ) override;
173 virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessibleColumnHeader( sal_uInt16 _nColumnPos ) override;
175 virtual sal_Int32 GetAccessibleControlCount() const override;
176 virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessibleControl( sal_Int32 _nIndex ) override;
177 virtual bool ConvertPointToControlIndex( sal_Int32& _rnIndex, const Point& _rPoint ) override;
179 virtual bool ConvertPointToCellAddress( sal_Int32& _rnRow, sal_uInt16& _rnColPos, const Point& _rPoint ) override;
180 virtual bool ConvertPointToRowHeader( sal_Int32& _rnRow, const Point& _rPoint ) override;
181 virtual bool ConvertPointToColumnHeader( sal_uInt16& _rnColPos, const Point& _rPoint ) override;
183 virtual OUString GetAccessibleObjectName( AccessibleBrowseBoxObjType _eType, sal_Int32 _nPos = -1 ) const override;
184 virtual OUString GetAccessibleObjectDescription( AccessibleBrowseBoxObjType _eType, sal_Int32 _nPos = -1 ) const override;
185 virtual vcl::Window* GetWindowInstance() override;
187 virtual void FillAccessibleStateSet( sal_Int64& _rStateSet, AccessibleBrowseBoxObjType _eType ) const override;
188 virtual void FillAccessibleStateSetForCell( sal_Int64& _rStateSet, sal_Int32 _nRow, sal_uInt16 _nColumn ) const override;
189 virtual void GrabTableFocus() override;
191 // OutputDevice
192 virtual bool GetGlyphBoundRects( const Point& rOrigin, const OUString& rStr, int nIndex, int nLen, std::vector< tools::Rectangle >& rVector ) override;
194 // Window
195 virtual tools::Rectangle GetWindowExtentsRelative(const vcl::Window *pRelativeWindow) const override;
196 virtual void GrabFocus() override;
197 virtual css::uno::Reference< css::accessibility::XAccessible > GetAccessible() override;
198 /** Creates and returns the accessible object of the whole BrowseBox. */
199 virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
200 virtual vcl::Window* GetAccessibleParentWindow() const override;
202 virtual tools::Rectangle GetFieldCharacterBounds(sal_Int32 _nRow,sal_Int32 _nColumnPos,sal_Int32 nIndex) override;
203 virtual sal_Int32 GetFieldIndexAtPoint(sal_Int32 _nRow,sal_Int32 _nColumnPos,const Point& _rPoint) override;
205 virtual void DumpAsPropertyTree(tools::JsonWriter& rJsonWriter) override;
208 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */