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 .
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>
30 struct ImplTabCtrlData
;
38 #define TAB_APPEND (sal_uInt16(0xFFFF))
39 #define TAB_PAGE_NOTFOUND (sal_uInt16(0xFFFF))
40 #endif /* !TAB_APPEND */
42 class VCL_DLLPUBLIC TabControl
: public Control
45 std::unique_ptr
<ImplTabCtrlData
> mpTabCtrlData
;
46 tools::Long mnLastWidth
;
47 tools::Long mnLastHeight
;
48 sal_uInt16 mnActPageId
;
49 sal_uInt16 mnCurPageId
;
53 bool mbSmallInvalidate
;
55 Link
<TabControl
*,void> maActivateHdl
;
56 Link
<TabControl
*,bool> maDeactivateHdl
;
58 using Control::ImplInitSettings
;
59 SAL_DLLPRIVATE
void ImplInitSettings( bool bBackground
);
60 SAL_DLLPRIVATE ImplTabItem
* ImplGetItem( sal_uInt16 nId
) const;
61 SAL_DLLPRIVATE ImplTabItem
* ImplGetItem(const Point
& rPt
) const;
62 SAL_DLLPRIVATE Size
ImplGetItemSize( ImplTabItem
* pItem
, tools::Long nMaxWidth
);
63 SAL_DLLPRIVATE
tools::Rectangle
ImplGetTabRect( sal_uInt16 nPos
, tools::Long nWidth
= -1, tools::Long nHeight
= -1 );
64 SAL_DLLPRIVATE
tools::Rectangle
ImplGetTabRect(const ImplTabItem
*, tools::Long nWidth
, tools::Long nHeight
);
65 SAL_DLLPRIVATE
void ImplChangeTabPage( sal_uInt16 nId
, sal_uInt16 nOldId
);
66 SAL_DLLPRIVATE
bool ImplPosCurTabPage();
67 virtual void ImplActivateTabPage( bool bNext
);
68 SAL_DLLPRIVATE
void ImplShowFocus();
69 SAL_DLLPRIVATE
void ImplDrawItem(vcl::RenderContext
& rRenderContext
, ImplTabItem
const * pItem
,
70 const tools::Rectangle
& rCurRect
, bool bFirstInGroup
,
72 SAL_DLLPRIVATE
bool ImplHandleKeyEvent( const KeyEvent
& rKeyEvent
);
74 DECL_DLLPRIVATE_LINK( ImplListBoxSelectHdl
, ListBox
&, void );
75 DECL_DLLPRIVATE_LINK( ImplWindowEventListener
, VclWindowEvent
&, void );
77 using Window::ImplInit
;
78 SAL_DLLPRIVATE
void ImplInit( vcl::Window
* pParent
, WinBits nStyle
);
80 virtual const vcl::Font
& GetCanonicalFont( const StyleSettings
& _rStyle
) const override
;
81 virtual const Color
& GetCanonicalTextColor( const StyleSettings
& _rStyle
) const override
;
82 virtual bool ImplPlaceTabs( tools::Long nWidth
);
83 SAL_DLLPRIVATE Size
ImplCalculateRequisition(sal_uInt16
& nHeaderHeight
) const;
86 TabControl( vcl::Window
* pParent
,
87 WinBits nStyle
= WB_STDTABCONTROL
);
88 virtual ~TabControl() override
;
89 virtual void dispose() override
;
91 virtual void MouseButtonDown( const MouseEvent
& rMEvt
) override
;
92 virtual void KeyInput( const KeyEvent
& rKEvt
) override
;
93 virtual void Paint( vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
94 virtual void Resize() override
;
95 virtual void GetFocus() override
;
96 virtual void LoseFocus() override
;
97 virtual void RequestHelp( const HelpEvent
& rHEvt
) override
;
98 virtual void Command( const CommandEvent
& rCEvt
) override
;
99 virtual bool EventNotify( NotifyEvent
& rNEvt
) override
;
100 virtual void StateChanged( StateChangedType nType
) override
;
101 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
102 virtual bool PreNotify( NotifyEvent
& rNEvt
) override
;
105 bool DeactivatePage();
107 virtual Size
GetOptimalSize() const override
;
109 void SetTabPageSizePixel( const Size
& rSize
);
111 void InsertPage( sal_uInt16 nPageId
, const OUString
& rText
,
112 sal_uInt16 nPos
= TAB_APPEND
);
113 void RemovePage( sal_uInt16 nPageId
);
115 void SetPageEnabled(sal_uInt16 nPageId
, bool bEnable
= true);
116 void SetPageVisible(sal_uInt16 nPageId
, bool bVisible
= true);
118 sal_uInt16
GetPagePos( sal_uInt16 nPageId
) const;
119 sal_uInt16
GetPageCount() const;
120 sal_uInt16
GetPageId( sal_uInt16 nPos
) const;
121 sal_uInt16
GetPageId(const Point
& rPos
) const;
122 sal_uInt16
GetPageId( const OUString
& rName
) const;
124 void SetCurPageId(sal_uInt16 nPageId
);
125 sal_uInt16
GetCurPageId() const;
127 void SelectTabPage( sal_uInt16 nPageId
);
129 void SetTabPage(sal_uInt16 nPageId
, TabPage
* pPage
);
130 TabPage
* GetTabPage( sal_uInt16 nPageId
) const;
132 void SetPageText( sal_uInt16 nPageId
, const OUString
& rText
);
133 OUString
const & GetPageText( sal_uInt16 nPageId
) const;
135 void SetHelpText( sal_uInt16 nPageId
, const OUString
& rText
);
136 const OUString
& GetHelpText( sal_uInt16 nPageId
) const;
138 void SetPageName( sal_uInt16 nPageId
, const OUString
& rName
) const;
139 OUString
GetPageName( sal_uInt16 nPageId
) const;
141 void SetAccessibleName( sal_uInt16 nItemId
, const OUString
& rStr
);
142 OUString
GetAccessibleName( sal_uInt16 nItemId
) const;
144 void SetAccessibleDescription( sal_uInt16 nItemId
, const OUString
& rStr
);
145 OUString
GetAccessibleDescription( sal_uInt16 nItemId
) const;
147 void SetPageImage( sal_uInt16 nPageId
, const Image
& rImage
);
149 using Control::SetHelpId
;
150 using Control::GetHelpId
;
152 void SetActivatePageHdl( const Link
<TabControl
*,void>& rLink
) { maActivateHdl
= rLink
; }
153 void SetDeactivatePageHdl( const Link
<TabControl
*, bool>& rLink
) { maDeactivateHdl
= rLink
; }
155 // returns the rectangle of the tab for page nPageId
156 tools::Rectangle
GetTabBounds( sal_uInt16 nPageId
) const;
158 virtual void SetPosPixel(const Point
& rPos
) override
;
159 virtual void SetSizePixel(const Size
& rNewSize
) override
;
160 virtual void SetPosSizePixel(const Point
& rNewPos
, const Size
& rNewSize
) override
;
162 virtual Size
calculateRequisition() const;
163 void setAllocation(const Size
&rAllocation
);
165 std::vector
<sal_uInt16
> GetPageIDs() const;
167 virtual FactoryFunction
GetUITestFactory() const override
;
169 virtual void queue_resize(StateChangedType eReason
= StateChangedType::Layout
) override
;
171 virtual bool set_property(const OUString
&rKey
, const OUString
&rValue
) override
;
173 virtual void DumpAsPropertyTree(tools::JsonWriter
&) override
;
178 class UNLESS_MERGELIBS(VCL_DLLPUBLIC
) NotebookbarTabControlBase
: public TabControl
,
179 public NotebookbarContextControl
182 NotebookbarTabControlBase( vcl::Window
* pParent
);
183 ~NotebookbarTabControlBase() override
;
184 void dispose() override
;
186 void SetContext( vcl::EnumContext::Context eContext
) override
;
187 void SetIconClickHdl( Link
<NotebookBar
*, void> aHdl
);
188 void SetToolBox( ToolBox
* pToolBox
);
189 ToolBox
* GetToolBox() { return m_pShortcuts
; }
190 Control
* GetOpenMenu();
192 virtual Size
calculateRequisition() const override
;
193 static sal_uInt16
GetHeaderHeight();
196 virtual bool ImplPlaceTabs( tools::Long nWidth
) override
;
197 virtual void ImplActivateTabPage( bool bNext
) override
;
200 bool bLastContextWasSupported
;
201 vcl::EnumContext::Context eLastContext
;
202 Link
<NotebookBar
*,void> m_aIconClickHdl
;
203 static sal_uInt16 m_nHeaderHeight
;
204 VclPtr
<ToolBox
> m_pShortcuts
;
205 VclPtr
<PushButton
> m_pOpenMenu
;
206 DECL_DLLPRIVATE_LINK(OpenMenu
, Button
*, void);
209 #endif // INCLUDED_VCL_TABCTRL_HXX
211 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */