Bump version to 21.06.18.1
[LibreOffice.git] / include / sfx2 / sidebar / TabBar.hxx
blob8a6b03f74d175835697579bcd3e98d09ed098594
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 <config_options.h>
22 #include <sfx2//dllapi.h>
23 #include <sfx2/sidebar/ResourceManager.hxx>
25 #include <vcl/InterimItemWindow.hxx>
26 #include <vcl/menu.hxx>
27 #include <vcl/window.hxx>
29 #include <functional>
31 namespace svt { class AcceleratorExecute; }
33 namespace weld { class Toolbar; }
35 namespace sfx2::sidebar {
37 class FocusManager;
38 class SidebarController;
40 /** The tab bar is the container for the individual tabs.
42 class TabBar final : public InterimItemWindow
44 public:
45 /** DeckMenuData has entries for display name, and a flag:
46 - isCurrentDeck for the deck selection data
47 - isEnabled for the show/hide menu
49 class DeckMenuData
51 public:
52 OUString msDisplayName;
53 bool mbIsCurrentDeck;
54 bool mbIsActive;
55 bool mbIsEnabled;
57 typedef ::std::function<void (
58 weld::Menu& rMainMenu, weld::Menu& rSubMenu,
59 const ::std::vector<DeckMenuData>& rMenuData)> PopupMenuProvider;
60 TabBar (
61 vcl::Window* pParentWindow,
62 const css::uno::Reference<css::frame::XFrame>& rxFrame,
63 const ::std::function<void (const OUString& rsDeckId)>& rDeckActivationFunctor,
64 const PopupMenuProvider& rPopupMenuProvider,
65 SidebarController* rParentSidebarController);
67 weld::Container* GetContainer() { return m_xContainer.get(); }
69 virtual ~TabBar() override;
70 virtual void dispose() override;
72 virtual void DataChanged (const DataChangedEvent& rDataChangedEvent) override;
73 virtual bool EventNotify (NotifyEvent& rEvent) override;
75 static sal_Int32 GetDefaultWidth();
77 void SetDecks (
78 const ResourceManager::DeckContextDescriptorContainer& rDecks);
79 void HighlightDeck (const OUString& rsDeckId);
80 void RemoveDeckHighlight ();
81 OUString const & GetDeckIdForIndex (const sal_Int32 nIndex) const;
82 void ToggleHideFlag (const sal_Int32 nIndex);
83 void RestoreHideFlags();
85 void UpdateFocusManager (FocusManager& rFocusManager);
87 /// Enables/Disables the menu button. Used by LoKit.
88 void EnableMenuButton(const bool bEnable);
90 private:
91 css::uno::Reference<css::frame::XFrame> mxFrame;
93 // This unusual auxillary builder is because without a toplevel GtkWindow
94 // gtk will warn on loading a .ui with an accelerator defined, so use a
95 // temporary toplevel to suppress that and move the contents after load
96 std::unique_ptr<weld::Builder> mxAuxBuilder;
97 std::unique_ptr<weld::Container> mxTempToplevel;
98 std::unique_ptr<weld::Widget> mxContents;
100 std::unique_ptr<weld::MenuButton> mxMenuButton;
101 std::unique_ptr<weld::Menu> mxMainMenu;
102 std::unique_ptr<weld::Menu> mxSubMenu;
103 std::unique_ptr<weld::Widget> mxMeasureBox;
104 class Item
106 private:
107 TabBar& mrTabBar;
108 std::unique_ptr<weld::Builder> mxBuilder;
109 public:
110 Item(TabBar& rTabBar);
111 ~Item();
112 DECL_LINK(HandleClick, const OString&, void);
113 std::unique_ptr<weld::Toolbar> mxButton;
114 OUString msDeckId;
115 ::std::function<void (const OUString& rsDeckId)> maDeckActivationFunctor;
116 bool mbIsHidden;
117 bool mbIsHiddenByDefault;
119 typedef ::std::vector<std::unique_ptr<Item>> ItemContainer;
120 ItemContainer maItems;
121 const ::std::function<void (const OUString& rsDeckId)> maDeckActivationFunctor;
122 PopupMenuProvider maPopupMenuProvider;
124 static void CreateTabItem(weld::Toolbar& rButton, const DeckDescriptor& rDeckDescriptor);
125 css::uno::Reference<css::graphic::XGraphic> GetItemImage(const DeckDescriptor& rDeskDescriptor) const;
126 void UpdateButtonIcons();
128 DECL_LINK(OnToolboxClicked, weld::ToggleButton&, void);
130 SidebarController* pParentSidebarController;
131 std::unique_ptr<svt::AcceleratorExecute> mpAccel;
136 } // end of namespace sfx2::sidebar
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */