LibreOffice Module sfx2 (master) 1
PanelTitleBar.cxx
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
24
25using namespace css;
26using namespace css::uno;
27
28namespace sfx2::sidebar {
29
30PanelTitleBar::PanelTitleBar(const OUString& rsTitle,
31 weld::Builder& rBuilder,
32 Panel* pPanel)
33 : TitleBar(rBuilder, Theme::Color_PanelTitleBarBackground),
34 mxExpander(rBuilder.weld_expander("expander")),
35 mpPanel(pPanel),
36 msIdent("button")
37{
38 mxExpander->set_label(rsTitle);
39 mxExpander->connect_expanded(LINK(this, PanelTitleBar, ExpandHdl));
40
41 // tdf#145801 lock the height to the size it needs with the "toolbar" button shown
42 // so all of the titlebars are the same height if the "toolbar" is hidden in some
43 // of them
44 mxToolBox->show();
45 mxTitlebar->set_size_request(-1, mxTitlebar->get_preferred_size().Height());
46 mxToolBox->hide();
47
48 assert(mpPanel);
49
51}
52
53void PanelTitleBar::SetTitle(const OUString& rsTitle)
54{
55 mxExpander->set_label(rsTitle);
56}
57
59{
60 return mxExpander->get_label();
61}
62
64{
65 mxExpander->set_expanded(mpPanel->IsExpanded());
66}
67
69{
70 Reference<lang::XComponent> xComponent(mxController, UNO_QUERY);
71 if (xComponent.is())
72 xComponent->dispose();
73 mxController.clear();
74 mpPanel = nullptr;
75 mxExpander.reset();
76}
77
78void PanelTitleBar::SetMoreOptionsCommand(const OUString& rsCommandName,
79 const css::uno::Reference<css::frame::XFrame>& rxFrame,
80 const css::uno::Reference<css::frame::XController>& rxController)
81{
82 if (rsCommandName == msMoreOptionsCommand)
83 return;
84
85 if (!msMoreOptionsCommand.isEmpty())
86 mxToolBox->hide();
87
88 msMoreOptionsCommand = rsCommandName;
89
90 if (msMoreOptionsCommand.isEmpty())
91 return;
92
94 mxToolBox->set_item_ident(0, msIdent);
95
96 Reference<lang::XComponent> xComponent(mxController, UNO_QUERY);
97 if (xComponent.is())
98 xComponent->dispose();
101 *mxToolBox, mrBuilder, msMoreOptionsCommand, rxFrame, rxController, true);
102
103 mxToolBox->show();
104}
105
107{
108 if (!mxController)
109 return;
110 mxController->click();
111 mxController->execute(0);
112}
113
114IMPL_LINK(PanelTitleBar, ExpandHdl, weld::Expander&, rExpander, void)
115{
116 if (!mpPanel)
117 return;
118 mpPanel->SetExpanded(rExpander.get_expanded());
119}
120
121} // end of namespace sfx2::sidebar
122
123/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::shared_ptr< Panel > mpPanel
static css::uno::Reference< css::frame::XToolbarController > CreateToolBoxController(ToolBox *pToolBox, const ToolBoxItemId nItemId, const OUString &rsCommandName, const css::uno::Reference< css::frame::XFrame > &rxFrame, const css::uno::Reference< css::frame::XController > &rxController, const css::uno::Reference< css::awt::XWindow > &rxParentWindow, const sal_Int32 nItemWidth, bool bSideBar)
virtual void HandleToolBoxItemClick() override
css::uno::Reference< css::frame::XToolbarController > mxController
void SetMoreOptionsCommand(const OUString &rsCommandName, const css::uno::Reference< css::frame::XFrame > &rxFrame, const css::uno::Reference< css::frame::XController > &rxController)
virtual void SetTitle(const OUString &rsTitle) override
virtual OUString GetTitle() const override
virtual ~PanelTitleBar() override
std::unique_ptr< weld::Expander > mxExpander
PanelTitleBar(const OUString &rsTitle, weld::Builder &rBuilder, Panel *pPanel)
Multiple panels form a single deck.
Definition: Panel.hxx:54
bool IsExpanded() const
Definition: Panel.hxx:74
Simple collection of colors, gradients, fonts that define the look of the sidebar and its controls.
Definition: Theme.hxx:44
weld::Builder & mrBuilder
Definition: TitleBar.hxx:54
std::unique_ptr< weld::Box > mxTitlebar
Definition: TitleBar.hxx:55
std::unique_ptr< weld::Toolbar > mxToolBox
Definition: TitleBar.hxx:57
IMPL_LINK(FocusManager, KeyInputHdl, const KeyEvent &, rKeyEvent, bool)