vcl: Merge SvHeaderTabListBoxImpl into SvHeaderTabListBox
[LibreOffice.git] / include / vcl / toolkit / svtabbx.hxx
blob322925b437bf34a5a29ffeba65ca5820dd641898
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 <config_options.h>
27 #include <accessibility/accessibletablistbox.hxx>
28 #include <vcl/dllapi.h>
29 #include <vcl/toolkit/treelistbox.hxx>
30 #include <vcl/accessibletableprovider.hxx>
32 #include <tools/debug.hxx>
34 #include <memory>
35 #include <vector>
37 enum class SvTabJustify
39 AdjustRight = static_cast<int>(SvLBoxTabFlags::ADJUST_RIGHT),
40 AdjustLeft = static_cast<int>(SvLBoxTabFlags::ADJUST_LEFT),
41 AdjustCenter = static_cast<int>(SvLBoxTabFlags::ADJUST_CENTER)
44 class UNLESS_MERGELIBS_MORE(VCL_DLLPUBLIC) SvTabListBox : public SvTreeListBox
46 private:
47 std::vector<SvLBoxTab> mvTabList;
48 OUString aCurEntry;
50 protected:
51 static std::u16string_view GetToken( std::u16string_view sStr, sal_Int32 &nIndex );
53 virtual void SetTabs() override;
54 virtual void InitEntry(SvTreeListEntry*, const OUString&, const Image&, const Image&) override;
56 OUString GetTabEntryText( sal_uInt32 nPos, sal_uInt16 nCol ) const;
57 SvTreeListEntry* GetEntryOnPos( sal_uInt32 _nEntryPos ) const;
58 SvTreeListEntry* GetChildOnPos( SvTreeListEntry* _pParent, sal_uInt32 _nEntryPos, sal_uInt32& _rPos ) const;
60 public:
61 SvTabListBox( vcl::Window* pParent, WinBits );
62 virtual ~SvTabListBox() override;
63 virtual void dispose() override;
64 void SetTabs(const std::vector<tools::Long>& rTabPositions, MapUnit = MapUnit::MapAppFont);
65 using SvTreeListBox::GetTab;
66 tools::Long GetLogicTab( sal_uInt16 nTab );
68 virtual SvTreeListEntry* InsertEntry( const OUString& rText, SvTreeListEntry* pParent = nullptr,
69 bool bChildrenOnDemand = false,
70 sal_uInt32 nPos=TREELIST_APPEND, void* pUserData = nullptr ) override;
72 virtual SvTreeListEntry* InsertEntryToColumn( const OUString&, SvTreeListEntry* pParent,
73 sal_uInt32 nPos, sal_uInt16 nCol, void* pUserData = nullptr );
75 virtual OUString GetEntryText( SvTreeListEntry* pEntry ) const override;
76 static OUString GetEntryText( const SvTreeListEntry*, sal_uInt16 nCol );
77 OUString GetEntryText( sal_uInt32 nPos, sal_uInt16 nCol = 0xffff ) const;
78 using SvTreeListBox::SetEntryText;
79 OUString GetCellText( sal_uInt32 nPos, sal_uInt16 nCol ) const;
80 sal_uInt32 GetEntryPos( const SvTreeListEntry* pEntry ) const;
82 void SetTabJustify( sal_uInt16 nTab, SvTabJustify );
83 void SetTabEditable( sal_uInt16 nTab, bool bEditable );
85 virtual void DumpAsPropertyTree(tools::JsonWriter& rJsonWriter) override;
88 // class SvHeaderTabListBox ---------------------------------------------------
90 class HeaderBar;
91 namespace vcl {
92 struct SvHeaderTabListBoxImpl;
95 class UNLESS_MERGELIBS_MORE(VCL_DLLPUBLIC) SvHeaderTabListBox : public SvTabListBox, public vcl::IAccessibleTableProvider
97 private:
98 bool m_bFirstPaint;
99 VclPtr<HeaderBar> m_xHeaderBar;
100 rtl::Reference<AccessibleTabListBox> m_xAccessible;
101 std::vector<css::uno::Reference<css::accessibility::XAccessible>> m_aAccessibleChildren;
103 Link<SvTreeListEntry*, bool> m_aEditingEntryHdl;
104 Link<const IterString&, bool> m_aEditedEntryHdl;
106 DECL_DLLPRIVATE_LINK( ScrollHdl_Impl, SvTreeListBox*, void );
107 DECL_DLLPRIVATE_LINK( CreateAccessibleHdl_Impl, HeaderBar*, void );
109 void RecalculateAccessibleChildren();
111 public:
112 SvHeaderTabListBox(vcl::Window* pParent, WinBits nBits, HeaderBar* pHeaderBar);
113 virtual ~SvHeaderTabListBox() override;
114 virtual void dispose() override;
116 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& ) override;
118 HeaderBar* GetHeaderBar();
119 static bool IsItemChecked( SvTreeListEntry* pEntry, sal_uInt16 nCol );
121 virtual SvTreeListEntry* InsertEntryToColumn( const OUString&, SvTreeListEntry* pParent,
122 sal_uInt32 nPos, sal_uInt16 nCol, void* pUserData = nullptr ) override;
123 virtual sal_uInt32 Insert( SvTreeListEntry* pEnt,SvTreeListEntry* pPar,sal_uInt32 nPos=TREELIST_APPEND) override;
124 virtual sal_uInt32 Insert( SvTreeListEntry* pEntry, sal_uInt32 nRootPos = TREELIST_APPEND ) override;
126 // Accessible -------------------------------------------------------------
128 bool IsCellCheckBox( sal_Int32 _nRow, sal_uInt16 _nColumn, TriState& _rState ) const;
130 /** @return The count of the rows. */
131 virtual sal_Int32 GetRowCount() const override;
132 /** @return The count of the columns. */
133 virtual sal_uInt16 GetColumnCount() const override;
135 /** @return The position of the current row. */
136 virtual sal_Int32 GetCurrRow() const override;
137 /** @return The position of the current column. */
138 virtual sal_uInt16 GetCurrColumn() const override;
140 /** @return The description of a row.
141 @param _nRow The row which description is in demand. */
142 virtual OUString GetRowDescription( sal_Int32 _nRow ) const override;
143 /** @return The description of a column.
144 @param _nColumn The column which description is in demand. */
145 virtual OUString GetColumnDescription( sal_uInt16 _nColumn ) const override;
147 /** @return <TRUE/>, if the object has a row header. */
148 virtual bool HasRowHeader() const override; //GetColumnId
149 /** @return <TRUE/>, if the object can focus a cell. */
150 virtual bool GoToCell( sal_Int32 _nRow, sal_uInt16 _nColumn ) override;
152 virtual void SetNoSelection() override;
153 using SvTabListBox::SelectAll;
154 virtual void SelectAll() override;
155 virtual void SelectRow( sal_Int32 _nRow, bool _bSelect = true, bool bExpand = true ) override;
156 virtual void SelectColumn( sal_uInt16 _nColumn, bool _bSelect = true ) override;
157 virtual sal_Int32 GetSelectedRowCount() const override;
158 virtual sal_Int32 GetSelectedColumnCount() const override;
159 /** @return <TRUE/>, if the row is selected. */
160 virtual bool IsRowSelected( sal_Int32 _nRow ) const override;
161 virtual bool IsColumnSelected( sal_Int32 _nColumn ) const override;
162 virtual void GetAllSelectedRows( css::uno::Sequence< sal_Int32 >& _rRows ) const override;
163 virtual void GetAllSelectedColumns( css::uno::Sequence< sal_Int32 >& _rColumns ) const override;
165 /** @return <TRUE/>, if the cell is visible. */
166 virtual bool IsCellVisible( sal_Int32 _nRow, sal_uInt16 _nColumn ) const override;
167 virtual OUString GetAccessibleCellText( sal_Int32 _nRow, sal_uInt16 _nColumnPos ) const override;
169 virtual tools::Rectangle calcHeaderRect( bool _bIsColumnBar, bool _bOnScreen = true ) override;
170 virtual tools::Rectangle calcTableRect( bool _bOnScreen = true ) override;
171 virtual tools::Rectangle GetFieldRectPixel( sal_Int32 _nRow, sal_uInt16 _nColumn, bool _bIsHeader, bool _bOnScreen ) override;
173 virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessibleCell( sal_Int32 _nRow, sal_uInt16 _nColumn ) override;
174 virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessibleRowHeader( sal_Int32 _nRow ) override;
175 virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessibleColumnHeader( sal_uInt16 _nColumnPos ) override;
177 virtual sal_Int32 GetAccessibleControlCount() const override;
178 virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessibleControl( sal_Int32 _nIndex ) override;
179 virtual bool ConvertPointToControlIndex( sal_Int32& _rnIndex, const Point& _rPoint ) override;
181 virtual bool ConvertPointToCellAddress( sal_Int32& _rnRow, sal_uInt16& _rnColPos, const Point& _rPoint ) override;
182 virtual bool ConvertPointToRowHeader( sal_Int32& _rnRow, const Point& _rPoint ) override;
183 virtual bool ConvertPointToColumnHeader( sal_uInt16& _rnColPos, const Point& _rPoint ) override;
185 virtual OUString GetAccessibleObjectName( AccessibleBrowseBoxObjType _eType, sal_Int32 _nPos = -1 ) const override;
186 virtual OUString GetAccessibleObjectDescription( AccessibleBrowseBoxObjType _eType, sal_Int32 _nPos = -1 ) const override;
187 virtual vcl::Window* GetWindowInstance() override;
189 virtual void FillAccessibleStateSet( sal_Int64& _rStateSet, AccessibleBrowseBoxObjType _eType ) const override;
190 virtual void FillAccessibleStateSetForCell( sal_Int64& _rStateSet, sal_Int32 _nRow, sal_uInt16 _nColumn ) const override;
191 virtual void GrabTableFocus() override;
193 // OutputDevice
194 virtual bool GetGlyphBoundRects( const Point& rOrigin, const OUString& rStr, int nIndex, int nLen, std::vector< tools::Rectangle >& rVector ) override;
196 // Window
197 virtual AbsoluteScreenPixelRectangle GetWindowExtentsAbsolute() const override;
198 virtual tools::Rectangle GetWindowExtentsRelative(const vcl::Window& rRelativeWindow) const override;
199 virtual void GrabFocus() override;
200 virtual css::uno::Reference< css::accessibility::XAccessible > GetAccessible() override;
201 /** Creates and returns the accessible object of the whole BrowseBox. */
202 virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
203 virtual vcl::Window* GetAccessibleParentWindow() const override;
205 virtual tools::Rectangle GetFieldCharacterBounds(sal_Int32 _nRow,sal_Int32 _nColumnPos,sal_Int32 nIndex) override;
206 virtual sal_Int32 GetFieldIndexAtPoint(sal_Int32 _nRow,sal_Int32 _nColumnPos,const Point& _rPoint) override;
208 virtual void DumpAsPropertyTree(tools::JsonWriter& rJsonWriter) override;
210 void SetEditingEntryHdl(const Link<SvTreeListEntry*, bool>& rLink)
212 m_aEditingEntryHdl = rLink;
215 void SetEditedEntryHdl(const Link<const IterString&, bool>& rLink)
217 m_aEditedEntryHdl = rLink;
220 //the default NotifyStartDrag is weird to me, and defaults to enabling all
221 //possibilities when drag starts, while restricting it to some subset of
222 //the configured drag drop mode would make more sense to me, but I'm not
223 //going to change the baseclass
224 virtual DragDropMode NotifyStartDrag() override { return GetDragDropMode(); }
226 virtual bool EditingEntry(SvTreeListEntry* pEntry) override
228 return m_aEditingEntryHdl.Call(pEntry);
231 virtual bool EditedEntry(SvTreeListEntry* pEntry, const OUString& rNewText) override
233 return m_aEditedEntryHdl.Call(IterString(pEntry, rNewText));
237 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */