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/TitleBar.hxx>
21 #include <vcl/help.hxx>
22 #include <vcl/svapp.hxx>
24 namespace sfx2::sidebar
{
26 TitleBar::TitleBar(weld::Builder
& rBuilder
, Theme::ThemeItem eThemeItem
)
28 , mxTitlebar(rBuilder
.weld_box(u
"titlebar"_ustr
))
29 , mxAddonImage(rBuilder
.weld_image(u
"addonimage"_ustr
))
30 , mxToolBox(rBuilder
.weld_toolbar(u
"toolbar"_ustr
))
31 , meThemeItem(eThemeItem
)
32 , msToolBoxRId(u
""_ustr
)
36 mxToolBox
->connect_clicked(LINK(this, TitleBar
, SelectionHandler
));
39 void TitleBar::SetBackground()
41 Color
aColor(Theme::GetColor(meThemeItem
));
42 mxTitlebar
->set_background(aColor
);
43 mxToolBox
->set_background(aColor
);
46 void TitleBar::DataChanged()
55 Size
TitleBar::get_preferred_size() const
57 return mxTitlebar
->get_preferred_size();
60 void TitleBar::Show(bool bShow
)
62 mxTitlebar
->set_visible(bShow
);
65 bool TitleBar::GetVisible() const
67 return mxTitlebar
->get_visible();
70 void TitleBar::SetIcon(const css::uno::Reference
<css::graphic::XGraphic
>& rIcon
)
72 mxAddonImage
->set_image(rIcon
);
73 mxAddonImage
->set_visible(rIcon
.is());
76 void TitleBar::ShowHelp(const OUString
& rHelpId
)
78 Help
* pHelp
= Application::GetHelp();
80 pHelp
->Start(rHelpId
);
83 IMPL_LINK(TitleBar
, SelectionHandler
, const OUString
&, rId
, void)
86 HandleToolBoxItemClick();
89 } // end of namespace sfx2::sidebar
91 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */