/src/libreoffice/include/sfx2/sidebar/TabBar.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | #pragma once |
20 | | |
21 | | #include <sfx2/sidebar/ResourceManager.hxx> |
22 | | |
23 | | #include <vcl/InterimItemWindow.hxx> |
24 | | #include <vcl/weld/Builder.hxx> |
25 | | |
26 | | #include <com/sun/star/graphic/XGraphic.hpp> |
27 | | |
28 | | #include <functional> |
29 | | |
30 | | namespace com::sun::star::frame { class XFrame; } |
31 | | namespace com::sun::star::graphic { class XGraphic; } |
32 | | |
33 | | namespace weld { class MenuButton; } |
34 | | namespace weld { class Toolbar; } |
35 | | |
36 | | namespace sfx2::sidebar { |
37 | | |
38 | | class FocusManager; |
39 | | class SidebarController; |
40 | | |
41 | | /** The tab bar is the container for the individual tabs. |
42 | | */ |
43 | | class TabBar final : public InterimItemWindow |
44 | | { |
45 | | friend class TabBarUIObject; |
46 | | public: |
47 | | typedef ::std::function<void ( |
48 | | weld::Menu& rMainMenu, weld::Menu& rSubMenu)> PopupMenuSignalConnectFunction; |
49 | | TabBar ( |
50 | | vcl::Window* pParentWindow, |
51 | | const css::uno::Reference<css::frame::XFrame>& rxFrame, |
52 | | ::std::function<void (const OUString& rsDeckId)> aDeckActivationFunctor, |
53 | | PopupMenuSignalConnectFunction aPopupMenuSignalConnectFunction, |
54 | | SidebarController& rParentSidebarController); |
55 | | |
56 | 0 | weld::Container* GetContainer() { return m_xContainer.get(); } |
57 | | |
58 | | virtual ~TabBar() override; |
59 | | virtual void dispose() override; |
60 | | |
61 | | virtual void DataChanged (const DataChangedEvent& rDataChangedEvent) override; |
62 | | virtual bool EventNotify (NotifyEvent& rEvent) override; |
63 | | |
64 | | static sal_Int32 GetDefaultWidth(); |
65 | | |
66 | | void SetDecks ( |
67 | | const ResourceManager::DeckContextDescriptorContainer& rDecks); |
68 | | void HighlightDeck (std::u16string_view rsDeckId); |
69 | | void RemoveDeckHighlight (); |
70 | | OUString const & GetDeckIdForIndex (const sal_Int32 nIndex) const; |
71 | | void ToggleHideFlag (const sal_Int32 nIndex); |
72 | | |
73 | | void UpdateFocusManager (FocusManager& rFocusManager); |
74 | | |
75 | | /// Enables/Disables the menu button. Used by LoKit. |
76 | | void EnableMenuButton(const bool bEnable); |
77 | | |
78 | | void UpdateMenus(); |
79 | | |
80 | | virtual FactoryFunction GetUITestFactory() const override; |
81 | | private: |
82 | | css::uno::Reference<css::frame::XFrame> mxFrame; |
83 | | |
84 | | // This unusual auxiliary builder is because without a toplevel GtkWindow |
85 | | // gtk will warn on loading a .ui with an accelerator defined, so use a |
86 | | // temporary toplevel to suppress that and move the contents after load |
87 | | std::unique_ptr<weld::Builder> mxAuxBuilder; |
88 | | std::unique_ptr<weld::Box> mxTempToplevel; |
89 | | std::unique_ptr<weld::Widget> mxContents; |
90 | | |
91 | | std::unique_ptr<weld::MenuButton> mxMenuButton; |
92 | | std::unique_ptr<weld::Menu> mxMainMenu; |
93 | | std::unique_ptr<weld::Menu> mxSubMenu; |
94 | | std::unique_ptr<weld::Widget> mxMeasureBox; |
95 | | class Item |
96 | | { |
97 | | private: |
98 | | TabBar& mrTabBar; |
99 | | std::unique_ptr<weld::Builder> mxBuilder; |
100 | | public: |
101 | | Item(TabBar& rTabBar); |
102 | | ~Item(); |
103 | | DECL_LINK(HandleClick, const OUString&, void); |
104 | | std::unique_ptr<weld::Toolbar> mxButton; |
105 | | OUString msDeckId; |
106 | | typedef ::std::function<void (const OUString& rsDeckId)> DeckActivationFunctor; |
107 | | DeckActivationFunctor maDeckActivationFunctor; |
108 | | bool mbIsHidden; |
109 | | }; |
110 | | typedef ::std::vector<std::unique_ptr<Item>> ItemContainer; |
111 | | ItemContainer maItems; |
112 | | const Item::DeckActivationFunctor maDeckActivationFunctor; |
113 | | |
114 | | void CreateTabItem(weld::Toolbar& rButton, const DeckDescriptor& rDeckDescriptor); |
115 | | css::uno::Reference<css::graphic::XGraphic> GetItemImage(const DeckDescriptor& rDeskDescriptor) const; |
116 | | void UpdateButtonIcons(); |
117 | | |
118 | | SidebarController& mrParentSidebarController; |
119 | | }; |
120 | | |
121 | | |
122 | | } // end of namespace sfx2::sidebar |
123 | | |
124 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |