LibreOffice Module sfx2 (master) 1
TabBar.hxx
Go to the documentation of this file.
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
22
24
25#include <functional>
26
27namespace com::sun::star::frame { class XFrame; }
28
29namespace svt { class AcceleratorExecute; }
30
31namespace weld { class Toolbar; }
32
33namespace sfx2::sidebar {
34
35class FocusManager;
36class SidebarController;
37
40class TabBar final : public InterimItemWindow
41{
42 friend class TabBarUIObject;
43public:
49 {
50 public:
51 OUString msDisplayName;
55 };
56 typedef ::std::function<void (
57 weld::Menu& rMainMenu, weld::Menu& rSubMenu,
58 const ::std::vector<DeckMenuData>& rMenuData)> PopupMenuProvider;
60 vcl::Window* pParentWindow,
61 const css::uno::Reference<css::frame::XFrame>& rxFrame,
62 ::std::function<void (const OUString& rsDeckId)> aDeckActivationFunctor,
63 PopupMenuProvider aPopupMenuProvider,
64 SidebarController* rParentSidebarController);
65
67
68 virtual ~TabBar() override;
69 virtual void dispose() override;
70
71 virtual void DataChanged (const DataChangedEvent& rDataChangedEvent) override;
72 virtual bool EventNotify (NotifyEvent& rEvent) override;
73
74 static sal_Int32 GetDefaultWidth();
75
76 void SetDecks (
78 void HighlightDeck (std::u16string_view rsDeckId);
79 void RemoveDeckHighlight ();
80 OUString const & GetDeckIdForIndex (const sal_Int32 nIndex) const;
81 void ToggleHideFlag (const sal_Int32 nIndex);
82 void RestoreHideFlags();
83
84 void UpdateFocusManager (FocusManager& rFocusManager);
85
87 void EnableMenuButton(const bool bEnable);
88
89 virtual FactoryFunction GetUITestFactory() const override;
90private:
91 css::uno::Reference<css::frame::XFrame> mxFrame;
92
93 // This unusual auxiliary 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::Box> mxTempToplevel;
98 std::unique_ptr<weld::Widget> mxContents;
99
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
105 {
106 private:
108 std::unique_ptr<weld::Builder> mxBuilder;
109 public:
110 Item(TabBar& rTabBar);
111 ~Item();
112 DECL_LINK(HandleClick, const OUString&, void);
113 std::unique_ptr<weld::Toolbar> mxButton;
114 OUString msDeckId;
115 ::std::function<void (const OUString& rsDeckId)> maDeckActivationFunctor;
118 };
119 typedef ::std::vector<std::unique_ptr<Item>> ItemContainer;
121 const ::std::function<void (const OUString& rsDeckId)> maDeckActivationFunctor;
123
124 void CreateTabItem(weld::Toolbar& rButton, const DeckDescriptor& rDeckDescriptor);
125 css::uno::Reference<css::graphic::XGraphic> GetItemImage(const DeckDescriptor& rDeskDescriptor) const;
126 void UpdateButtonIcons();
127
128 DECL_LINK(OnToolboxClicked, weld::Toggleable&, void);
129
131 std::unique_ptr<svt::AcceleratorExecute> mpAccel;
132
133};
134
135
136} // end of namespace sfx2::sidebar
137
138/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< weld::Container > m_xContainer
Concentrate all focus handling in this class.
std::vector< DeckContextDescriptor > DeckContextDescriptorContainer
DeckMenuData has entries for display name, and a flag:
Definition: TabBar.hxx:49
std::unique_ptr< weld::Toolbar > mxButton
Definition: TabBar.hxx:113
::std::function< void(const OUString &rsDeckId)> maDeckActivationFunctor
Definition: TabBar.hxx:115
DECL_LINK(HandleClick, const OUString &, void)
std::unique_ptr< weld::Builder > mxBuilder
Definition: TabBar.hxx:108
Item(TabBar &rTabBar)
Definition: TabBar.cxx:256
The tab bar is the container for the individual tabs.
Definition: TabBar.hxx:41
std::unique_ptr< weld::Menu > mxSubMenu
Definition: TabBar.hxx:102
std::unique_ptr< weld::Widget > mxContents
Definition: TabBar.hxx:98
std::unique_ptr< weld::Menu > mxMainMenu
Definition: TabBar.hxx:101
virtual bool EventNotify(NotifyEvent &rEvent) override
Definition: TabBar.cxx:183
DECL_LINK(OnToolboxClicked, weld::Toggleable &, void)
void UpdateFocusManager(FocusManager &rFocusManager)
Definition: TabBar.cxx:330
void SetDecks(const ResourceManager::DeckContextDescriptorContainer &rDecks)
Definition: TabBar.cxx:120
virtual FactoryFunction GetUITestFactory() const override
Definition: TabBar.cxx:385
void RemoveDeckHighlight()
Definition: TabBar.cxx:169
SidebarController * pParentSidebarController
Definition: TabBar.hxx:130
void HighlightDeck(std::u16string_view rsDeckId)
Definition: TabBar.cxx:163
virtual void DataChanged(const DataChangedEvent &rDataChangedEvent) override
Definition: TabBar.cxx:175
std::unique_ptr< weld::Widget > mxMeasureBox
Definition: TabBar.hxx:103
std::unique_ptr< weld::MenuButton > mxMenuButton
Definition: TabBar.hxx:100
void CreateTabItem(weld::Toolbar &rButton, const DeckDescriptor &rDeckDescriptor)
Definition: TabBar.cxx:236
css::uno::Reference< css::frame::XFrame > mxFrame
Definition: TabBar.hxx:91
void EnableMenuButton(const bool bEnable)
Enables/Disables the menu button. Used by LoKit.
Definition: TabBar.cxx:380
PopupMenuProvider maPopupMenuProvider
Definition: TabBar.hxx:122
void UpdateButtonIcons()
Definition: TabBar.cxx:152
::std::vector< std::unique_ptr< Item > > ItemContainer
Definition: TabBar.hxx:119
std::unique_ptr< svt::AcceleratorExecute > mpAccel
Definition: TabBar.hxx:131
weld::Container * GetContainer()
Definition: TabBar.hxx:66
ItemContainer maItems
Definition: TabBar.hxx:120
const ::std::function< void(const OUString &rsDeckId)> maDeckActivationFunctor
Definition: TabBar.hxx:121
TabBar(vcl::Window *pParentWindow, const css::uno::Reference< css::frame::XFrame > &rxFrame, ::std::function< void(const OUString &rsDeckId)> aDeckActivationFunctor, PopupMenuProvider aPopupMenuProvider, SidebarController *rParentSidebarController)
OUString const & GetDeckIdForIndex(const sal_Int32 nIndex) const
Definition: TabBar.cxx:286
virtual ~TabBar() override
Definition: TabBar.cxx:90
css::uno::Reference< css::graphic::XGraphic > GetItemImage(const DeckDescriptor &rDeskDescriptor) const
Definition: TabBar.cxx:248
static sal_Int32 GetDefaultWidth()
Definition: TabBar.cxx:109
::std::function< void(weld::Menu &rMainMenu, weld::Menu &rSubMenu, const ::std::vector< DeckMenuData > &rMenuData)> PopupMenuProvider
Definition: TabBar.hxx:58
void ToggleHideFlag(const sal_Int32 nIndex)
Definition: TabBar.cxx:293
virtual void dispose() override
Definition: TabBar.cxx:95
std::unique_ptr< weld::Builder > mxAuxBuilder
Definition: TabBar.hxx:96
std::unique_ptr< weld::Box > mxTempToplevel
Definition: TabBar.hxx:97
std::function< std::unique_ptr< UIObject >(vcl::Window *)> FactoryFunction