bump product version to 7.6.3.2-android
[LibreOffice.git] / include / vcl / tabctrl.hxx
blobc6dc7f2fcb23b36032550464e2980700bab30b51
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 #ifndef INCLUDED_VCL_TABCTRL_HXX
21 #define INCLUDED_VCL_TABCTRL_HXX
23 #include <config_options.h>
24 #include <vcl/dllapi.h>
25 #include <vcl/ctrl.hxx>
26 #include <vcl/EnumContext.hxx>
27 #include <vcl/NotebookbarContextControl.hxx>
29 class ImplTabItem;
30 struct ImplTabCtrlData;
31 class TabPage;
32 class Button;
33 class PushButton;
34 class ListBox;
35 class ToolBox;
37 #ifndef TAB_APPEND
38 #define TAB_APPEND (sal_uInt16(0xFFFF))
39 #define TAB_PAGE_NOTFOUND (sal_uInt16(0xFFFF))
40 #endif /* !TAB_APPEND */
42 #define TAB_OFFSET 3
43 #define TAB_TABOFFSET_X 3
44 #define TAB_TABOFFSET_Y 3
45 #define TAB_EXTRASPACE_X 6
46 #define TAB_BORDER_LEFT 1
47 #define TAB_BORDER_TOP 1
48 #define TAB_BORDER_RIGHT 2
49 #define TAB_BORDER_BOTTOM 2
51 class VCL_DLLPUBLIC TabControl : public Control
53 protected:
54 std::unique_ptr<ImplTabCtrlData> mpTabCtrlData;
55 tools::Long mnLastWidth;
56 tools::Long mnLastHeight;
57 sal_uInt16 mnActPageId;
58 sal_uInt16 mnCurPageId;
59 bool mbFormat;
60 bool mbShowTabs;
61 bool mbRestoreHelpId;
62 bool mbSmallInvalidate;
63 bool mbLayoutDirty;
64 Link<TabControl*,void> maActivateHdl;
65 Link<TabControl*,bool> maDeactivateHdl;
67 using Control::ImplInitSettings;
68 SAL_DLLPRIVATE void ImplInitSettings( bool bBackground );
69 SAL_DLLPRIVATE ImplTabItem* ImplGetItem( sal_uInt16 nId ) const;
70 SAL_DLLPRIVATE ImplTabItem* ImplGetItem(const Point& rPt) const;
71 SAL_DLLPRIVATE Size ImplGetItemSize( ImplTabItem* pItem, tools::Long nMaxWidth );
72 SAL_DLLPRIVATE tools::Rectangle ImplGetTabRect( sal_uInt16 nPos, tools::Long nWidth = -1, tools::Long nHeight = -1 );
73 SAL_DLLPRIVATE tools::Rectangle ImplGetTabRect(const ImplTabItem*, tools::Long nWidth, tools::Long nHeight);
74 SAL_DLLPRIVATE void ImplChangeTabPage( sal_uInt16 nId, sal_uInt16 nOldId );
75 SAL_DLLPRIVATE bool ImplPosCurTabPage();
76 virtual void ImplActivateTabPage( bool bNext );
77 SAL_DLLPRIVATE void ImplShowFocus();
78 SAL_DLLPRIVATE void ImplDrawItem(vcl::RenderContext& rRenderContext, ImplTabItem const * pItem,
79 const tools::Rectangle& rCurRect, bool bFirstInGroup,
80 bool bLastInGroup);
81 SAL_DLLPRIVATE void ImplFreeLayoutData();
82 SAL_DLLPRIVATE bool ImplHandleKeyEvent( const KeyEvent& rKeyEvent );
84 DECL_DLLPRIVATE_LINK( ImplListBoxSelectHdl, ListBox&, void );
85 DECL_DLLPRIVATE_LINK( ImplWindowEventListener, VclWindowEvent&, void );
87 using Window::ImplInit;
88 SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
90 virtual void FillLayoutData() const override;
91 virtual const vcl::Font& GetCanonicalFont( const StyleSettings& _rStyle ) const override;
92 virtual const Color& GetCanonicalTextColor( const StyleSettings& _rStyle ) const override;
93 virtual bool ImplPlaceTabs( tools::Long nWidth );
94 SAL_DLLPRIVATE Size ImplCalculateRequisition(sal_uInt16& nHeaderHeight) const;
96 public:
97 TabControl( vcl::Window* pParent,
98 WinBits nStyle = WB_STDTABCONTROL );
99 virtual ~TabControl() override;
100 virtual void dispose() override;
102 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
103 virtual void KeyInput( const KeyEvent& rKEvt ) override;
104 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
105 virtual void Resize() override;
106 virtual void GetFocus() override;
107 virtual void LoseFocus() override;
108 virtual void RequestHelp( const HelpEvent& rHEvt ) override;
109 virtual void Command( const CommandEvent& rCEvt ) override;
110 virtual bool EventNotify( NotifyEvent& rNEvt ) override;
111 virtual void StateChanged( StateChangedType nType ) override;
112 virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
113 virtual bool PreNotify( NotifyEvent& rNEvt ) override;
115 void ActivatePage();
116 bool DeactivatePage();
118 virtual Size GetOptimalSize() const override;
120 void SetTabPageSizePixel( const Size& rSize );
122 void InsertPage( sal_uInt16 nPageId, const OUString& rText,
123 sal_uInt16 nPos = TAB_APPEND );
124 void RemovePage( sal_uInt16 nPageId );
126 void SetPageEnabled(sal_uInt16 nPageId, bool bEnable = true);
127 void SetPageVisible(sal_uInt16 nPageId, bool bVisible = true);
129 sal_uInt16 GetPagePos( sal_uInt16 nPageId ) const;
130 sal_uInt16 GetPageCount() const;
131 sal_uInt16 GetPageId( sal_uInt16 nPos ) const;
132 sal_uInt16 GetPageId(const Point& rPos) const;
133 sal_uInt16 GetPageId( const OUString& rName ) const;
135 void SetCurPageId(sal_uInt16 nPageId);
136 sal_uInt16 GetCurPageId() const;
138 void SelectTabPage( sal_uInt16 nPageId );
140 void SetTabPage(sal_uInt16 nPageId, TabPage* pPage);
141 TabPage* GetTabPage( sal_uInt16 nPageId ) const;
143 void SetPageText( sal_uInt16 nPageId, const OUString& rText );
144 OUString const & GetPageText( sal_uInt16 nPageId ) const;
146 void SetHelpText( sal_uInt16 nPageId, const OUString& rText );
147 const OUString& GetHelpText( sal_uInt16 nPageId ) const;
149 void SetPageName( sal_uInt16 nPageId, const OUString& rName ) const;
150 OUString GetPageName( sal_uInt16 nPageId ) const;
152 void SetAccessibleName( sal_uInt16 nItemId, const OUString& rStr );
153 OUString GetAccessibleName( sal_uInt16 nItemId ) const;
155 void SetAccessibleDescription( sal_uInt16 nItemId, const OUString& rStr );
156 OUString GetAccessibleDescription( sal_uInt16 nItemId ) const;
158 void SetPageImage( sal_uInt16 nPageId, const Image& rImage );
160 using Control::SetHelpId;
161 using Control::GetHelpId;
163 void SetActivatePageHdl( const Link<TabControl*,void>& rLink ) { maActivateHdl = rLink; }
164 void SetDeactivatePageHdl( const Link<TabControl*, bool>& rLink ) { maDeactivateHdl = rLink; }
166 // returns (control relative) bounding rectangle for the
167 // character at index nIndex relative to the text of page nPageId
168 using Control::GetCharacterBounds;
169 tools::Rectangle GetCharacterBounds( sal_uInt16 nPageId, tools::Long nIndex ) const;
171 // returns the index relative to the text of page nPageId (also returned)
172 // at position rPoint (control relative)
173 using Control::GetIndexForPoint;
174 tools::Long GetIndexForPoint( const Point& rPoint, sal_uInt16& rPageId ) const;
176 // returns the rectangle of the tab for page nPageId
177 tools::Rectangle GetTabBounds( sal_uInt16 nPageId ) const;
179 virtual void SetPosPixel(const Point& rPos) override;
180 virtual void SetSizePixel(const Size& rNewSize) override;
181 virtual void SetPosSizePixel(const Point& rNewPos, const Size& rNewSize) override;
183 virtual Size calculateRequisition() const;
184 void setAllocation(const Size &rAllocation);
186 std::vector<sal_uInt16> GetPageIDs() const;
188 virtual FactoryFunction GetUITestFactory() const override;
190 virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override;
192 virtual bool set_property(const OUString &rKey, const OUString &rValue) override;
194 virtual void DumpAsPropertyTree(tools::JsonWriter&) override;
197 class NotebookBar;
199 class UNLESS_MERGELIBS(VCL_DLLPUBLIC) NotebookbarTabControlBase : public TabControl,
200 public NotebookbarContextControl
202 public:
203 NotebookbarTabControlBase( vcl::Window* pParent );
204 ~NotebookbarTabControlBase() override;
205 void dispose() override;
207 void SetContext( vcl::EnumContext::Context eContext ) override;
208 void SetIconClickHdl( Link<NotebookBar*, void> aHdl );
209 void SetToolBox( ToolBox* pToolBox );
210 ToolBox* GetToolBox() { return m_pShortcuts; }
211 Control* GetOpenMenu();
213 virtual Size calculateRequisition() const override;
214 static sal_uInt16 GetHeaderHeight();
216 protected:
217 virtual bool ImplPlaceTabs( tools::Long nWidth ) override;
218 virtual void ImplActivateTabPage( bool bNext ) override;
220 private:
221 bool bLastContextWasSupported;
222 vcl::EnumContext::Context eLastContext;
223 Link<NotebookBar*,void> m_aIconClickHdl;
224 static sal_uInt16 m_nHeaderHeight;
225 VclPtr<ToolBox> m_pShortcuts;
226 VclPtr<PushButton> m_pOpenMenu;
227 DECL_DLLPRIVATE_LINK(OpenMenu, Button*, void);
230 #endif // INCLUDED_VCL_TABCTRL_HXX
232 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */