/src/libreoffice/svx/source/form/labelitemwindow.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ |
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 | | |
10 | | #include <svx/labelitemwindow.hxx> |
11 | | #include <vcl/svapp.hxx> |
12 | | #include <vcl/weld/Builder.hxx> |
13 | | |
14 | | LabelItemWindow::LabelItemWindow(vcl::Window* pParent, const OUString& rLabel) |
15 | 0 | : InterimItemWindow(pParent, u"svx/ui/labelbox.ui"_ustr, u"LabelBox"_ustr) |
16 | 0 | , m_xBox(m_xBuilder->weld_box(u"LabelBox"_ustr)) |
17 | 0 | , m_xLabel(m_xBuilder->weld_label(u"label"_ustr)) |
18 | 0 | , m_xImage(m_xBuilder->weld_image(u"image"_ustr)) |
19 | 0 | { |
20 | 0 | InitControlBase(m_xLabel.get()); |
21 | |
|
22 | 0 | m_xLabel->set_label(rLabel); |
23 | 0 | m_xImage->hide(); |
24 | 0 | m_xImage->set_size_request(24, 24); // vcl/res/infobar.png is 32x32 - too large here |
25 | |
|
26 | 0 | SetOptimalSize(); |
27 | |
|
28 | 0 | m_xLabel->set_toolbar_background(); |
29 | 0 | } Unexecuted instantiation: LabelItemWindow::LabelItemWindow(vcl::Window*, rtl::OUString const&) Unexecuted instantiation: LabelItemWindow::LabelItemWindow(vcl::Window*, rtl::OUString const&) |
30 | | |
31 | | void LabelItemWindow::SetOptimalSize() |
32 | 0 | { |
33 | 0 | Size aSize(m_xBox->get_preferred_size()); |
34 | 0 | aSize.AdjustWidth(12); |
35 | |
|
36 | 0 | SetSizePixel(aSize); |
37 | 0 | } |
38 | | |
39 | | void LabelItemWindow::set_label(const OUString& rLabel, const LabelItemWindowType eType) |
40 | 0 | { |
41 | | // hide temporarily, to trigger a11y announcement for SHOWING event for |
42 | | // the label with NOTIFICATION a11y role when label gets shown again below |
43 | 0 | if (!rLabel.isEmpty()) |
44 | 0 | m_xLabel->set_visible(false); |
45 | |
|
46 | 0 | m_xLabel->set_label(rLabel); |
47 | 0 | if ((eType == LabelItemWindowType::Text) || rLabel.isEmpty()) |
48 | 0 | { |
49 | 0 | m_xImage->hide(); |
50 | 0 | m_xLabel->set_font_color(COL_AUTO); |
51 | 0 | m_xBox->set_background(); // reset to default |
52 | 0 | } |
53 | 0 | else if (eType == LabelItemWindowType::Info) |
54 | 0 | { |
55 | 0 | m_xImage->show(); |
56 | 0 | const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); |
57 | 0 | if (rStyleSettings.GetDialogColor().IsDark()) |
58 | 0 | m_xBox->set_background(Color(0x00, 0x56, 0x80)); |
59 | 0 | else |
60 | 0 | m_xBox->set_background(Color(0xBD, 0xE5, 0xF8)); // same as InfobarType::INFO |
61 | 0 | } |
62 | 0 | m_xLabel->set_visible( |
63 | 0 | true); // always show and not just if !rLabel.isEmpty() to not make the chevron appear |
64 | 0 | } |
65 | | |
66 | 0 | OUString LabelItemWindow::get_label() const { return m_xLabel->get_label(); } |
67 | | |
68 | | void LabelItemWindow::dispose() |
69 | 0 | { |
70 | 0 | m_xImage.reset(); |
71 | 0 | m_xLabel.reset(); |
72 | 0 | m_xBox.reset(); |
73 | 0 | InterimItemWindow::dispose(); |
74 | 0 | } |
75 | | |
76 | 0 | LabelItemWindow::~LabelItemWindow() { disposeOnce(); } |
77 | | |
78 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |