Simplify using designated initializers
[LibreOffice.git] / include / sfx2 / sidebar / TabBar.hxx
blob7e3bcfeb28a2ea5828a9a44c526d1cbd8fcbf36c
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 .
19 #pragma once
21 #include <sfx2/sidebar/ResourceManager.hxx>
23 #include <vcl/InterimItemWindow.hxx>
25 #include <functional>
27 namespace com::sun::star::frame { class XFrame; }
29 namespace sfx2::sidebar {
31 class FocusManager;
32 class SidebarController;
34 /** The tab bar is the container for the individual tabs.
36 class TabBar final : public InterimItemWindow
38 friend class TabBarUIObject;
39 public:
40 typedef ::std::function<void (
41 weld::Menu& rMainMenu, weld::Menu& rSubMenu)> PopupMenuSignalConnectFunction;
42 TabBar (
43 vcl::Window* pParentWindow,
44 const css::uno::Reference<css::frame::XFrame>& rxFrame,
45 ::std::function<void (const OUString& rsDeckId)> aDeckActivationFunctor,
46 PopupMenuSignalConnectFunction aPopupMenuSignalConnectFunction,
47 SidebarController& rParentSidebarController);
49 weld::Container* GetContainer() { return m_xContainer.get(); }
51 virtual ~TabBar() override;
52 virtual void dispose() override;
54 virtual void DataChanged (const DataChangedEvent& rDataChangedEvent) override;
55 virtual bool EventNotify (NotifyEvent& rEvent) override;
57 static sal_Int32 GetDefaultWidth();
59 void SetDecks (
60 const ResourceManager::DeckContextDescriptorContainer& rDecks);
61 void HighlightDeck (std::u16string_view rsDeckId);
62 void RemoveDeckHighlight ();
63 OUString const & GetDeckIdForIndex (const sal_Int32 nIndex) const;
64 void ToggleHideFlag (const sal_Int32 nIndex);
66 void UpdateFocusManager (FocusManager& rFocusManager);
68 /// Enables/Disables the menu button. Used by LoKit.
69 void EnableMenuButton(const bool bEnable);
71 void UpdateMenus();
73 virtual FactoryFunction GetUITestFactory() const override;
74 private:
75 css::uno::Reference<css::frame::XFrame> mxFrame;
77 // This unusual auxiliary builder is because without a toplevel GtkWindow
78 // gtk will warn on loading a .ui with an accelerator defined, so use a
79 // temporary toplevel to suppress that and move the contents after load
80 std::unique_ptr<weld::Builder> mxAuxBuilder;
81 std::unique_ptr<weld::Box> mxTempToplevel;
82 std::unique_ptr<weld::Widget> mxContents;
84 std::unique_ptr<weld::MenuButton> mxMenuButton;
85 std::unique_ptr<weld::Menu> mxMainMenu;
86 std::unique_ptr<weld::Menu> mxSubMenu;
87 std::unique_ptr<weld::Widget> mxMeasureBox;
88 class Item
90 private:
91 TabBar& mrTabBar;
92 std::unique_ptr<weld::Builder> mxBuilder;
93 public:
94 Item(TabBar& rTabBar);
95 ~Item();
96 DECL_LINK(HandleClick, const OUString&, void);
97 std::unique_ptr<weld::Toolbar> mxButton;
98 OUString msDeckId;
99 typedef ::std::function<void (const OUString& rsDeckId)> DeckActivationFunctor;
100 DeckActivationFunctor maDeckActivationFunctor;
101 bool mbIsHidden;
103 typedef ::std::vector<std::unique_ptr<Item>> ItemContainer;
104 ItemContainer maItems;
105 const Item::DeckActivationFunctor maDeckActivationFunctor;
107 void CreateTabItem(weld::Toolbar& rButton, const DeckDescriptor& rDeckDescriptor);
108 css::uno::Reference<css::graphic::XGraphic> GetItemImage(const DeckDescriptor& rDeskDescriptor) const;
109 void UpdateButtonIcons();
111 SidebarController& mrParentSidebarController;
115 } // end of namespace sfx2::sidebar
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */