1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
20 #include <sidebar/PanelTitleBar.hxx>
21 #include <sfx2/sidebar/Panel.hxx>
22 #include <sfx2/sidebar/Theme.hxx>
23 #include <sidebar/ControllerFactory.hxx>
26 using namespace css::uno
;
28 namespace sfx2::sidebar
{
30 PanelTitleBar::PanelTitleBar(const OUString
& rsTitle
,
31 weld::Builder
& rBuilder
,
33 : TitleBar(rBuilder
, Theme::Color_PanelTitleBarBackground
),
34 mxExpander(rBuilder
.weld_expander(u
"expander"_ustr
)),
36 msIdent(u
"button"_ustr
)
38 mxExpander
->set_label(rsTitle
);
39 mxExpander
->connect_expanded(LINK(this, PanelTitleBar
, ExpandHdl
));
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
45 mxTitlebar
->set_size_request(-1, mxTitlebar
->get_preferred_size().Height());
50 UpdateExpandedState();
53 void PanelTitleBar::SetTitle(const OUString
& rsTitle
)
55 mxExpander
->set_label(rsTitle
);
58 OUString
PanelTitleBar::GetTitle() const
60 return mxExpander
->get_label();
63 void PanelTitleBar::UpdateExpandedState()
65 mxExpander
->set_expanded(mpPanel
->IsExpanded());
68 PanelTitleBar::~PanelTitleBar()
70 Reference
<lang::XComponent
> xComponent(mxController
, UNO_QUERY
);
72 xComponent
->dispose();
78 void PanelTitleBar::SetMoreOptionsCommand(const OUString
& rsCommandName
,
79 const css::uno::Reference
<css::frame::XFrame
>& rxFrame
,
80 const css::uno::Reference
<css::frame::XController
>& rxController
)
82 if (rsCommandName
== msMoreOptionsCommand
)
85 if (!msMoreOptionsCommand
.isEmpty())
88 msMoreOptionsCommand
= rsCommandName
;
90 if (msMoreOptionsCommand
.isEmpty())
93 msIdent
= msMoreOptionsCommand
;
94 mxToolBox
->set_item_ident(0, msIdent
);
96 Reference
<lang::XComponent
> xComponent(mxController
, UNO_QUERY
);
98 xComponent
->dispose();
100 ControllerFactory::CreateToolBoxController(
101 *mxToolBox
, mrBuilder
, msMoreOptionsCommand
, rxFrame
, rxController
, true);
106 void PanelTitleBar::HandleToolBoxItemClick()
110 mxController
->click();
111 mxController
->execute(0);
114 IMPL_LINK(PanelTitleBar
, ExpandHdl
, weld::Expander
&, rExpander
, void)
118 mpPanel
->SetExpanded(rExpander
.get_expanded());
121 } // end of namespace sfx2::sidebar
123 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */