/src/libreoffice/sfx2/source/sidebar/TitleBar.cxx
Line | Count | Source |
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 | | |
20 | | #include <sidebar/TitleBar.hxx> |
21 | | #include <vcl/help.hxx> |
22 | | #include <vcl/svapp.hxx> |
23 | | |
24 | | namespace sfx2::sidebar { |
25 | | |
26 | | TitleBar::TitleBar(weld::Builder& rBuilder, Theme::ThemeItem eThemeItem) |
27 | 0 | : mrBuilder(rBuilder) |
28 | 0 | , mxTitlebar(rBuilder.weld_box(u"titlebar"_ustr)) |
29 | 0 | , mxAddonImage(rBuilder.weld_image(u"addonimage"_ustr)) |
30 | 0 | , mxToolBox(rBuilder.weld_toolbar(u"toolbar"_ustr)) |
31 | 0 | , meThemeItem(eThemeItem) |
32 | 0 | , msToolBoxRId(u""_ustr) |
33 | 0 | { |
34 | 0 | SetBackground(); |
35 | |
|
36 | 0 | mxToolBox->connect_clicked(LINK(this, TitleBar, SelectionHandler)); |
37 | 0 | } |
38 | | |
39 | | void TitleBar::SetBackground() |
40 | 0 | { |
41 | 0 | Color aColor(Theme::GetColor(meThemeItem)); |
42 | 0 | mxTitlebar->set_background(aColor); |
43 | 0 | mxToolBox->set_background(aColor); |
44 | 0 | } |
45 | | |
46 | | void TitleBar::DataChanged() |
47 | 0 | { |
48 | 0 | SetBackground(); |
49 | 0 | } |
50 | | |
51 | | TitleBar::~TitleBar() |
52 | 0 | { |
53 | 0 | } |
54 | | |
55 | | Size TitleBar::get_preferred_size() const |
56 | 0 | { |
57 | 0 | return mxTitlebar->get_preferred_size(); |
58 | 0 | } |
59 | | |
60 | | void TitleBar::Show(bool bShow) |
61 | 0 | { |
62 | 0 | mxTitlebar->set_visible(bShow); |
63 | 0 | } |
64 | | |
65 | | bool TitleBar::GetVisible() const |
66 | 0 | { |
67 | 0 | return mxTitlebar->get_visible(); |
68 | 0 | } |
69 | | |
70 | | void TitleBar::SetIcon(const css::uno::Reference<css::graphic::XGraphic>& rIcon) |
71 | 0 | { |
72 | 0 | mxAddonImage->set_image(rIcon); |
73 | 0 | mxAddonImage->set_visible(rIcon.is()); |
74 | 0 | } |
75 | | |
76 | | void TitleBar::ShowHelp(const OUString& rHelpId) |
77 | 0 | { |
78 | 0 | Help* pHelp = Application::GetHelp(); |
79 | 0 | if (pHelp) |
80 | 0 | pHelp->Start(rHelpId); |
81 | 0 | } |
82 | | |
83 | | IMPL_LINK(TitleBar, SelectionHandler, const OUString&, rId, void) |
84 | 0 | { |
85 | 0 | msToolBoxRId = rId; |
86 | 0 | HandleToolBoxItemClick(); |
87 | 0 | } |
88 | | |
89 | | } // end of namespace sfx2::sidebar |
90 | | |
91 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |